Dictionary ex. from Wed

2228 days ago by amelia7

d={'Professor':'Calckin', 'Subject': 'Math', 'Course':3600} 
       
type(d) 
       
<type 'dict'>
<type 'dict'>
d['Professor'] 
       
'Calckin'
'Calckin'
d['Course'] 
       
3600
3600
d['Subject'] 
       
'Math'
'Math'
print d 
       
{'Course': 3600, 'Professor': 'Calckin', 'Subject': 'Math'}
{'Course': 3600, 'Professor': 'Calckin', 'Subject': 'Math'}
d.keys() 
       
['Course', 'Professor', 'Subject']
['Course', 'Professor', 'Subject']
d.values() 
       
[3600, 'Calckin', 'Math']
[3600, 'Calckin', 'Math']
d.has_key('Subject') 
       
True
True
d.items() 
       
[('Course', 3600), ('Professor', 'Calckin'), ('Subject', 'Math')]
[('Course', 3600), ('Professor', 'Calckin'), ('Subject', 'Math')]
d['Subject']='Maths' #changed math to maths 
       
       
{'Course': 3600, 'Professor': 'Calckin', 'Subject': 'Maths'}
{'Course': 3600, 'Professor': 'Calckin', 'Subject': 'Maths'}
d['Course']+=10 
       
       
{'Course': 3610, 'Professor': 'Calckin', 'Subject': 'Maths'}
{'Course': 3610, 'Professor': 'Calckin', 'Subject': 'Maths'}