File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Print out the 10th item in each.
2
+ #
3
+ # Print out the 45th key in the dictionary.
4
+ #
5
+ # Print out the 27th value in the dictionary.
6
+
7
+ import os , sys
8
+
9
+ # Import the data file
10
+ print (os .getcwd ())
11
+ base_dir = os .getcwd ().split ("\\ " )
12
+ separator = "\\ "
13
+ proj_directory_path = separator .join (base_dir [:- 1 ])
14
+ data_file_dir = os .path .join (proj_directory_path , "days\\ 07-09-data-structures\\ code" )
15
+ sys .path .insert (1 , data_file_dir )
16
+ print (sys .path )
17
+
18
+ import data
19
+
20
+ us_state_abbrev_dict = data .us_state_abbrev
21
+ # print(us_state_abbrev_dict)
22
+
23
+ us_states_list = data .states_list
24
+ # print(us_states_list)
25
+
26
+ sorted (us_state_abbrev_dict )
27
+ print (us_state_abbrev_dict )
28
+
29
+ # print the 10th item in the dict
30
+ tenth_item = {k : us_state_abbrev_dict [k ] for k in sorted (us_state_abbrev_dict .keys ())[9 :10 ]}
31
+ print (tenth_item )
32
+
33
+ # print the 10th item in list
34
+ us_states_list .sort ()
35
+ tenth_in_list = us_states_list [9 ]
36
+ print (tenth_in_list )
37
+
38
+
39
+ # Print out the 45th key in the dictionary.
40
+ forty_fifth_key = {k for k in sorted (us_state_abbrev_dict .keys ())[44 :45 ]}
41
+ print (forty_fifth_key )
42
+
43
+ # Print out the 27th value in the dictionary if sorted on values.
44
+ twenty_seventh_val = {k for k in sorted (us_state_abbrev_dict .values ())[26 :27 ]}
45
+ print (twenty_seventh_val )
You can’t perform that action at this time.
0 commit comments