Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Write a program that reads the data in rawdata.txt into a dictionary whose keys are country names and whose values are per capita incomes. Also

Write a program that reads the data in rawdata.txt into a dictionary whose keys are country names and whose values are per capita incomes. Also create another dictionary whose keys are letters A- Z and whose values are sets of country names. Convert the country names to all uppercase for both dictionaries Your program should prompt the user to enter country names and print the corresponding values. ? If the user enters a string with only one letter (like A) print all the countries that begin with that letter, ? If the user enters a string that contains more than one letter, print the corresponding value for that country if it exists or print Does not exist if invalid. ? Stop when the user enters quit.

This is done in python 3

rawdata.txt

1 Qatar $ 98,900

2 Liechtenstein $ 89,400

3 Luxembourg $ 80,600

4 Bermuda $ 69,900

5 Singapore $ 59,700

6 Jersey $ 57,000

7 Falkland Islands (Islas Malvinas) $ 55,400

8 Norway $ 53,400

9 Brunei $ 49,500

10 Hong Kong $ 49,400

11 United States $ 48,300

12 United Arab Emirates $ 47,700

13 Guernsey $ 44,600

14 Switzerland $ 44,500

15 Cayman Islands $ 43,800

16 Gibraltar $ 43,000

17 Netherlands $ 42,000

18 Kuwait $ 41,700

19 Austria $ 41,600

20 Ireland $ 40,800

21 Australia $ 40,800

22 Sweden $ 40,700

23 Canada $ 40,500

24 British Virgin Islands $ 38,500

25 Iceland $ 38,100

26 Germany $ 38,100

27 Belgium $ 37,800

28 Taiwan $ 37,700

29 Greenland $ 37,400

30 Andorra $ 37,200

31 Denmark $ 37,000

32 United Kingdom $ 36,500

33 San Marino $ 36,200

34 Finland $ 36,000

35 France $ 35,100

36 Isle of Man $ 35,000

37 Japan $ 34,700

38 European Union $ 34,100

39 Macau $ 33,000

40 Israel $ 31,500

41 Korea, South $ 31,200

42 Spain $ 30,500

43 Faroe Islands $ 30,500

44 Italy $ 30,500

45 Bahamas, The $ 30,400

46 Slovenia $ 28,800

47 New Zealand $ 28,000

48 Bahrain $ 27,700

49 Oman $ 27,600

50 Cyprus $ 27,500

51 Czech Republic $ 27,100

52 Greece $ 26,300

53 Malta $ 25,600

54 Seychelles $ 25,400

55 Barbados $ 25,000

56 Saudi Arabia $ 24,400

57 Portugal $ 23,400

58 Slovakia $ 23,300

59 Aruba $ 21,800

60 Estonia $ 20,400

61 Poland $ 20,200

62 Trinidad and Tobago $ 20,000

63 Hungary $ 19,600

64 Equatorial Guinea $ 19,300

65 Lithuania $ 19,100

66 Croatia $ 18,000

67 French Polynesia $ 18,000

68 Argentina $ 17,700

69 Chile $ 17,400

70 Antigua and Barbuda $ 17,100

71 Latvia $ 16,800

72 Russia $ 16,700

73 Puerto Rico $ 16,300

74 Gabon $ 16,300

75 Malaysia $ 16,200

76 Botswana $ 16,100

77 Saint Kitts and Nevis $ 15,600

78 Lebanon $ 15,500

79 Sint Maarten $ 15,400

80 Uruguay $ 15,100

81 New Caledonia $ 15,000

82 Mauritius $ 15,000

83 Belarus $ 15,000

84 Curacao $ 15,000

85 Guam $ 15,000

86 Mexico $ 14,700

87 Virgin Islands $ 14,500

88 Turkey $ 14,400

89 Dominica $ 14,300

90 Panama $ 14,100

91 Grenada $ 13,800

92 Bulgaria $ 13,800

93 Iran $ 13,200

94 Saint Lucia $ 13,100

95 Kazakhstan $ 13,000

96 Venezuela $ 12,600

97 Northern Mariana Islands $ 12,500

98 Romania $ 12,500

99 Anguilla $ 12,200

100 Costa Rica $ 11,900

101 Suriname $ 11,800

102 Brazil $ 11,800

103 Montenegro $ 11,500

104 Turks and Caicos Islands $ 11,500

105 Saint Vincent and the Grenadines $ 11,500

106 South Africa $ 11,000

107 Macedonia $ 10,500

108 Serbia $ 10,400

109 Azerbaijan $ 10,200

110 Colombia $ 10,200

111 Peru $ 10,100

112 Cuba $ 9,900

113 Tunisia $ 9,400

114 Thailand $ 9,400

115 Dominican Republic $ 9,300

116 Cook Islands $ 9,100

117 Jamaica $ 8,900

118 Timor-Leste $ 8,700

119 Maldives $ 8,600

120 Ecuador $ 8,500

121 Montserrat $ 8,500

122 China $ 8,400

123 Belize $ 8,200

124 Bosnia and Herzegovina $ 8,100

125 Palau $ 8,100

126 American Samoa $ 8,000

127 Albania $ 7,800

128 Turkmenistan $ 7,800

129 Guyana $ 7,600

130 El Salvador $ 7,500

131 Namibia $ 7,500

132 Algeria $ 7,300

133 Tonga $ 7,300

134 Ukraine $ 7,200

135 Saint Pierre and Miquelon $ 7,000

136 Kosovo $ 6,500

137 Egypt $ 6,500

138 Paraguay $ 6,200

139 Libya $ 6,000

140 Samoa $ 6,000

141 Jordan $ 5,900

142 Angola $ 5,900

143 Bhutan $ 5,800

144 Niue $ 5,800

145 Kiribati $ 5,700

146 Sri Lanka $ 5,700

147 Georgia $ 5,500

148 Armenia $ 5,400

149 Swaziland $ 5,300

150 Morocco $ 5,100

151 Guatemala $ 5,100

152 Syria $ 5,100

153 Nauru $ 5,000

154 Mongolia $ 4,800

155 Bolivia $ 4,800

156 Vanuatu $ 4,800

157 Indonesia $ 4,700

158 Fiji $ 4,600

159 Congo, Republic of the $ 4,500

160 Honduras $ 4,400

161 Iraq $ 4,200

162 Philippines $ 4,100

163 Cape Verde $ 3,900

164 Wallis and Futuna $ 3,800

165 India $ 3,700

166 Vietnam $ 3,400

167 Moldova $ 3,400

168 Uzbekistan $ 3,300

169 Tuvalu $ 3,300

170 Solomon Islands $ 3,200

171 Nicaragua $ 3,200

172 Ghana $ 3,100

173 West Bank $ 2,900

174 Laos $ 2,800

175 Pakistan $ 2,800

176 Sudan $ 2,700

177 Djibouti $ 2,600

178 Nigeria $ 2,600

179 Papua New Guinea $ 2,500

180 Marshall Islands $ 2,500

181 Western Sahara $ 2,500

182 Saint Helena, Ascension, and Tristan da Cunha $ 2,500

183 Kyrgyzstan $ 2,400

184 Sao Tome and Principe $ 2,300

185 Cameroon $ 2,300

186 Yemen $ 2,300

187 Micronesia, Federated States of $ 2,200

188 Cambodia $ 2,200

189 Tajikistan $ 2,100

190 South Sudan $ 2,100

191 Mauritania $ 2,000

192 Senegal $ 2,000

193 Chad $ 1,900

194 Gambia, The $ 1,900

195 Bangladesh $ 1,900

196 Lesotho $ 1,900

197 Korea, North $ 1,800

198 Kenya $ 1,700

199 Tanzania $ 1,600

200 Benin $ 1,600

201 Cote d'Ivoire $ 1,600

202 Zambia $ 1,600

203 Uganda $ 1,400

204 Burma $ 1,300

205 Burkina Faso $ 1,300

206 Rwanda $ 1,300

207 Nepal $ 1,200

208 Haiti $ 1,200

209 Comoros $ 1,200

210 Guinea $ 1,100

211 Ethiopia $ 1,100

212 Sierra Leone $ 1,100

213 Mali $ 1,100

214 Mozambique $ 1,100

215 Guinea-Bissau $ 1,100

216 Togo $ 1,000

217 Afghanistan $ 1,000

218 Tokelau $ 1,000

219 Madagascar $ 900

220 Malawi $ 900

221 Central African Republic $ 800

222 Niger $ 800

223 Eritrea $ 700

224 Somalia $ 600

225 Liberia $ 600

226 Burundi $ 600

227 Zimbabwe $ 500

228 Congo, Democratic Republic of the $ 300

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students explore these related Databases questions