-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathsample4.py
More file actions
21 lines (17 loc) · 735 Bytes
/
sample4.py
File metadata and controls
21 lines (17 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# let's takle a look at some basic data structures, the list and the dictionary
# list
starts = ['3', '3:30', '2', '10:30', '1:30', '3', '4:30', '1:30', '3', '4:30']
ends = ['5PM', '6:30PM', '5PM', '12NOON', '3PM', '4:30PM', '6PM', '3PM', '4:30PM', '6PM']
print len(starts)
print starts[0]
print starts[:5]
# dictionary
d = {'5:30-7PM': 5, '8:30-5:30PM': 3, '9-1PM': 13, '7:30-10:30PM': 4, '5:30-6PM': 1, '6:30-8:30PM': 25, '9-4:30PM': 2, '7-10PM': 4, '5:30-7:30PM': 16, '7-7PM': 22}
print d['5:30-7PM']
d['5:30-7PM'] += 1
print d['5:30-7PM']
# the below line will cause an error if you uncomment it, because the dictionary doesn't have a key '6-9PM' in it
# d['6-9PM'] += 1
#
# test if a dictionary has a key
# d.has_key('6-9PM')