code for chapter 5

This commit is contained in:
Aditya Bhargava
2016-03-02 14:32:36 -08:00
parent 3d9a7000c7
commit 8b9893cdc0
2 changed files with 18 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
book = dict()
# an apple costs 67 cents
book["apple"] = 0.67
# milk costs $1.49
book["milk"] = 1.49
book["avocado"] = 1.49
print book

View File

@@ -0,0 +1,11 @@
voted = {}
def check_voter(name):
if voted.get(name):
print "kick them out!"
else:
voted[name] = True
print "let them vote!"
check_voter("tom")
check_voter("mike")
check_voter("mike")