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 data for any four states of your choice. Then, report this count but use a function to get the count. Use a while loop to add more abbreviations and capitals. The loop should continue until the user presses Enter when prompted for an abbreviation.
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 data for any four states of your choice. Then, report this count but use a function to get the count. Use a while loop to add more abbreviations and capitals. The loop should continue until the user presses Enter when prompted for an abbreviation.
Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter13: Decision Making Under Uncertainty
Section13.4: Decision Trees
Problem 5P
Related questions
Question
PYTHON QUESTION
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 data for any four states of your choice. Then, report this count but use a function to get the count.
- Use a while loop to add more abbreviations and capitals. The loop should continue until 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 the items() method, display all the state abbreviations and their capitals.
In the same Python program write this code, although it has nothing to do with the states code.
- Using a dictionary comprehension, create a dictionary with the odd integers from 1 to 9 as keys and their cubes as values.
- Use a for loop to display the keys and values but without using the items() method.
Sample Output
( See attached photo )
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole