Question

PYTHON QUESTION# 5) 15 points Update the nations_big_cities dictionary nations big cities ChileSantiago CanadaVancouver Egypt : Cairo, Japan:Tokyo,j # Write code to fix an error in the dictionary #10 points Update the entry for Canada to Toronto without looking at any other country Close 8 points if your code examines each item) # 5points Print the contents of the dictionary, one country and city per line Example Chile largest city Santiago Canada largest city Toronto

0 0
Add a comment Improve this question Transcribed image text
Answer #1

5) you can directly write this statement since we do not want to look at any other country.

nations_big_cities['Canada'] = 'Toronto'

This will update the disctionary's key Canada to have a value Toronto. syntax is dict_name[key] = value. Sample output is here

For part two and printing of content of dictionary we can use

for key in nations_big_cities:

print("{} largest city {}".format(key, nations_big_cities[key]))

For loop will iterate over all the elements of the dictionary. print statement has a syntax of one value represented by {} followed by "largest city" and another value and the respective values being key and value of the dictionary.

Add a comment
Know the answer?
Add Answer to:
PYTHON QUESTION # 5) 15 points Update the nations_big_cities dictionary nations big cities 'Chile''Santiago CanadaVancouver' Egypt'...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT