ASSIGNMENT REQUIREMENTS This assignment requires a dictionary of state abbreviations and their capital cities . The abbreviations are the keys and the state capitals are the values . Start by entering...



ASSIGNMENT REQUIREMENTS



  • This assignment requires a dictionary ofstate abbreviations and their capital cities.  The abbreviations are thekeys and the state capitals are thevalues.

  • Start by entering data forany four states of your choice.  Then, report this count butuse a function to get the count.

  • Use awhile loopto add more abbreviations and capitals. The loop should continueuntil the user presses Enter when prompted for an abbreviation.


Inside the while loop:



  • If the state entered is already in the dictionary, report its capital.

  • If it is not in the dictionary, prompt the user to enter the capital for that state and add it to the dictionary


After the while loop ends:



  • Report again the count of the number of states in the dictionary.

  • Using another loop and theitems() method, display all the state abbreviations and their capitals.


In the same Python program write this code, although it hasnothing to do with the states code.



  • Using adictionary comprehension, create a dictionary with theodd integers from 1 to 9 askeys and theircubes as values.

  • Use afor loop to display the keys and values butwithout using the items() method.



Sample Output Attached:


4 states are in the dictionary<br>Let's add a few more<br>Enter state abbrev. or Enter to quit CA<br>Enter capital of CA Sacramento<br>Enter state abbrev. or Enter to quit KS<br>Already have KS, capital is Topeka<br>Enter state abbrev. or Enter to quit CÓ<br>Enter capital of CO Denver<br>Enter state abbrev. or Enter to quit WI<br>Enter capital of WI Madison<br>Enter state abbrev. or Enter to quit<br>Got 7 states now. Here they are...<br>The capital of ID is Boise<br>The capital of SD is Pierre<br>The capital of ME is Augusta<br>The capital of KS is Topeka<br>The capital of CA is Sacramento<br>The capital of CO is Denver<br>The capital of WI is Madison<br>Some cubes made with a dictionary comprehension...<br>1 cubed is 1<br>3 cubed is 27<br>5 cubed is 125<br>7 cubed is 343<br>9 cubed is 729<br>

Extracted text: 4 states are in the dictionary Let's add a few more Enter state abbrev. or Enter to quit CA Enter capital of CA Sacramento Enter state abbrev. or Enter to quit KS Already have KS, capital is Topeka Enter state abbrev. or Enter to quit CÓ Enter capital of CO Denver Enter state abbrev. or Enter to quit WI Enter capital of WI Madison Enter state abbrev. or Enter to quit Got 7 states now. Here they are... The capital of ID is Boise The capital of SD is Pierre The capital of ME is Augusta The capital of KS is Topeka The capital of CA is Sacramento The capital of CO is Denver The capital of WI is Madison Some cubes made with a dictionary comprehension... 1 cubed is 1 3 cubed is 27 5 cubed is 125 7 cubed is 343 9 cubed is 729
Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here