Vocabulary/Words
: Variables and Reserved words (Chapter 2)
Sentence structure
: Valid syntax patterns (Chapter 3-5)
Story structure
: Constructing a program for a purpose
: You cannot use reserved words as variavle names / identifiers
False | class | return | is | finally |
None | if | for | lambda | continue |
True | def | from | while | nonlocal |
and | del | global | not | with |
as | elif | try | or | yield |
assert | else | import | pass | |
break | except | in | raise |
//Sequential
name = input('Enter file:')
handle = open(name, 'r')
counts = dict()
//Repeated
for line in handle:
words = line.split()
for word in words:
counts[word] = counts.get(word, 0) + 1
bigcount = None
bigword = None
for word.count in counts.items():
//Conditional
if bigcount is None of count > bigcount:
bigword = word
bigcount = count
print(bigword, bigcount)