-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex39_test.py
42 lines (31 loc) · 1.13 KB
/
ex39_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import hashmap
states = hashmap.new()
hashmap.set(states, 'Oregon', 'OR')
hashmap.set(states, 'Florida', 'FL')
hashmap.set(states, 'California', 'CA')
hashmap.set(states, 'New York', 'NY')
hashmap.set(states, 'Michigan', 'MI')
cities = hashmap.new()
hashmap.set(cities, 'CA', 'San Fran')
hashmap.set(cities, 'MI', 'Detroit')
hashmap.set(cities, 'FL', 'Jacksonville')
hashmap.set(cities, 'NY', 'New York')
hashmap.set(cities, 'OR', 'Portland')
print '_' * 10
print "NY state has: %s" % hashmap.get(cities, 'NY')
print "OR state has %s" % hashmap.get(cities, 'OR')
print '_' * 10
print "Michigan's abbreviation is: %s" % hashmap.get(states, 'Michigan')
print "Florida's abbreviation is: %s" % hashmap.get(states, 'Florida')
print '_' * 10
print "Michigan has %s" % hashmap.get(cities, hashmap.get(states, 'Michigan'))
print "Florida has %s" % hashmap.get(cities, hashmap.get(states, 'Florida'))
print '_' * 10
hashmap.list(states)
print '_' * 10
hashmap.list(cities)
print '_' * 10
state = hashmap.get(states, 'Texas')
if not state:
print "sorry, no Texas."
print "The city for the state 'TX' is: %s" % hashmap.get(cities, 'TX', 'Does Not Exist')