notesonly.in

One notebook for every subject — open it anywhere.

Log in

Python basics: syntax, lists, dictionaries, functions

Programming Fundamentals · Engineering

Study notes

Word frequency in Python: text="hi hi hello"; freq={}; for w in text.split(): freq[w]=freq.get(w,0)+1; print(freq) gives {'hi':2,'hello':1}. Dictionaries count in O(1) average per lookup.

← Back to topics for Engineering