63 831
Assignments Done
99,2%
Successfully Done
In August 2018

Answer to Question #61020 in Python for Joyce

Question #61020

Write a loop that prints each country's population in country_pop. Sample output for the given program:
United States has 318463000 people.
India has 1247220000 people.
Indonesia has 252164800 people.
China has 1365830000 people.
Expert's answer
country_pop={"United States": 318463000, "India" : 1247220000, "Indonesia" : 25216480, "China": 1365830000 }

for key,value in country_pop.items(): print(key +" has "+ str(value) +" people.")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
14.02.18, 15:21

James, no difference in the code, just other variables names.

james
14.02.18, 06:37

for country,pop in country_pop.items():
##This works.

Assignment Expert
24.01.18, 20:58

$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> country_pop={"United States": 318463000, "India" : 1247220000, "Indonesia" : 25216480, "China": 1365830000 }
>>>
>>> for key,value in country_pop.items(): print(key +" has "+ str(value) +" people.")
...
China has 1365830000 people.
India has 1247220000 people.
United States has 318463000 people.
Indonesia has 25216480 people.
>>>

lamar
24.01.18, 20:45

this doesnt work

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions