Text Editor, Command Line, Machine Code
# python comment
now your turn
importing modules
(even your own)
#Choose a Name from a Hat
import random
fruit = ['apple', 'banana', 'orange']
random.choice(fruit)
now your turn
when lists are so wonderful...
and dictionaries are UNORDERED
so many emails to remember ;(
#contacts
emails = {'mark': '[email protected]',
'tom': '[email protected]',
'brendan': '[email protected]',
'zev': '[email protected]'}
#live code:
#look up zev's email
#add a new email
#change mark's email
now your turn
len() |
|
.get |
|
.update |
|
now your turn
(as a grocery store owner)
iterating through lists, dictionaries
names = ['mark', 'tom', 'zev', 'brendan']
names = ['mark', 'tom', 'zev', 'brendan']
enumerate #beauty of python vs. C
break |
|
continue |
|
now your turn
(print names, skipping every other name)
Create a Function to