1 |
Midterm Handout A for e02 |
CS8 S18 |
Dictionary states
The dictionary states
maps state abbreviations such as AZ
and CA
to dictionaries with information
about states of the United States. The three items in those dictionaries are:
"name"
: the name of the state (e.g. “Arizona”, or “California”)"capital"
: the capital city of that state (e.g. “Sacramento”)"largest"
: the largest city in that state (e.g. “Los Angeles”)"baseball"
: the names of the major league professional baseball teams in that state, if any.
The dictionary states
only has information about five western states.
On the back of this handout is another example of one of these dictionaries, with information on
a few eastern states.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
states = {
"AZ" : { "name": "Arizona",
"capital" : "Phoenix",
"largest": "Phoenix",
"baseball": ["Diamondbacks"] },
"CA" : { "name": "California",
"capital" : "Sacramento",
"largest" : "Los Angeles",
"baseball": ["Angels","Dogders","A's","Padres","Giants"] },
"NV" : { "name" : "Nevada",
"capital" : "Carson City",
"largest" : "Las Vegas",
"baseball" : [] },
"OR" : { "name" : "Oregon",
"capital" : "Salem",
"largest" : "Portland",
"baseball" : [] },
"WA" : { "name" : "Washington",
"capital" : "Olympia",
"largest" : "Seattle",
"baseball" : ["Mariners"] },
}
Midterm Handout A for CS8, Final Exam, S18, Page 2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
eastern_states = {
"NY" : { "name": "New York",
"capital" : "Albany",
"largest": "New York",
"baseball": ["Mets","Yankees"] },
"PA" : { "name": "Pennsylvania",
"capital" : "Harrisburg",
"largest" : "Philadelphia",
"baseball": ["Phillies","Pirates"] },
"MD" : { "name" : "Maryland",
"capital" : "Annapolis",
"largest" : "Baltimore",
"baseball" : [Orioles] },
"NJ" : { "name" : "New Jersey",
"capital" : "Trenton",
"largest" : "Newark",
"baseball" : [] },
"DE" : { "name" : "Delaware",
"capital" : "Dover",
"largest" : "Wilmington",
"baseball" : [] },
}
End of Handout