1 # MichiganCities.py - This program prints a message invalid cities in Michigan. Summary 2 # Input: Interactive 3 # Output: Error message or nothing In this lab, you use what you have learned about searching a list to find an exact match to 4 complete a partially prewritten Python program. 5 # Initialized list of cities 6 citiesInMichigan = ["Acme", "Albion", "Detroit", "Watervliet", "Coloma", "Saginaw", "Richland", "Glen "Midland", "Brooklyn"] 7 The program uses a list that contains valid names for 10 cities in Michigan. You ask the user to enter a city name; your program then searches the list for that city name. If it is not found, the program should print a message that informs the user the city name is not found in the list of valid 8 # Get user input cities in Michigan. 9 inCity = input("Enter name of city: ") 10 11 The starter file provided for this lab includes input statements. You need to write code to examine 12 # Write your test statement here to see if there is 13 |14 # If the city is found, print "City found." 15 '16 # Otherwise, "Not a city in Michigan" message should all the items in the list and test for a match. You also need to determine if you should print the "Not a city in Michigan." message. Comments in the code tell you where to write your statements. printed. Instructions 1. Study the prewritten code to make sure you understand it. 2. Write a loop statement that examines the names of cities stored in the list. 3. Write code that tests for a match. 4. Write code that, when appropriate, prints the message "Not a city in Michigan.". 5. Execute the program using the following as input: Chicago Brooklyn Watervliet Acme

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
1 # MichiganCities.py - This program prints a message
invalid cities in Michigan.
Summary
2 # Input: Interactive
3 # Output: Error message or nothing
In this lab, you use what you have learned about searching a list to find an exact match to
4
complete a partially prewritten Python program.
5 # Initialized list of cities
6 citiesInMichigan = ["Acme", "Albion", "Detroit",
"Watervliet", "Coloma", "Saginaw", "Richland", "Glen
"Midland", "Brooklyn"]
The program uses a list that contains valid names for 10 cities in Michigan. You ask the user to
enter a city name; your program then searches the list for that city name. If it is not found, the
7
program should print a message that informs the user the city name is not found in the list of valid
8 # Get user input
cities in Michigan.
9 inCity = input ("Enter name of city: ")
10
11
The starter file provided for this lab includes input statements. You need to write code to examine
12 # Write your test statement here to see if there is
all the items in the list and test for a match. You also need to determine if you should print the
13
"Not a city in Michigan." message.
|14 # If the city is found, print "City found."
15
Comments in the code tell you where to write your statements.
'16 # Otherwise, "Not a city in Michigan" message should
printed.
Instructions
1. Study the prewritten code to make sure you understand it.
2. Write a loop statement that examines the names of cities stored in the list.
3. Write code that tests for a match.
4. Write code that, when appropriate, prints the message "Not a city in Michigan.".
5. Execute the program using the following as input:
Chicago
Brooklyn
Watervliet
Acme
Transcribed Image Text:1 # MichiganCities.py - This program prints a message invalid cities in Michigan. Summary 2 # Input: Interactive 3 # Output: Error message or nothing In this lab, you use what you have learned about searching a list to find an exact match to 4 complete a partially prewritten Python program. 5 # Initialized list of cities 6 citiesInMichigan = ["Acme", "Albion", "Detroit", "Watervliet", "Coloma", "Saginaw", "Richland", "Glen "Midland", "Brooklyn"] The program uses a list that contains valid names for 10 cities in Michigan. You ask the user to enter a city name; your program then searches the list for that city name. If it is not found, the 7 program should print a message that informs the user the city name is not found in the list of valid 8 # Get user input cities in Michigan. 9 inCity = input ("Enter name of city: ") 10 11 The starter file provided for this lab includes input statements. You need to write code to examine 12 # Write your test statement here to see if there is all the items in the list and test for a match. You also need to determine if you should print the 13 "Not a city in Michigan." message. |14 # If the city is found, print "City found." 15 Comments in the code tell you where to write your statements. '16 # Otherwise, "Not a city in Michigan" message should printed. Instructions 1. Study the prewritten code to make sure you understand it. 2. Write a loop statement that examines the names of cities stored in the list. 3. Write code that tests for a match. 4. Write code that, when appropriate, prints the message "Not a city in Michigan.". 5. Execute the program using the following as input: Chicago Brooklyn Watervliet Acme
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY

Expert Answers to Latest Homework Questions

Q: A 3.5-kg block is pushed 2.9 m up a vertical wall with constant speed by a constant force of…
Q: An elastic bar of the length L and cross section area A is rigidly attached to the ceiling of a…
Q: What role did the Fourth-Amendment play in applying the protections offered by the Bill of Rights to…
Q: Why did the anti- federalists demand a Bill of rights? What are some of the key protections offered…
Q: An elastic bar of the length L and cross section area A is rigidly attached to the ceiling of a…
Q: Using A36 steel select the lightest equal leg single angle member to resist a factored (LRFD)…
Q: Los Angeles's demand for water exceeds the amount of water available. There are no other new sources…
Q: For the following circuit. What is Vr. Additionally, what is the threshold input voltage VL that…
Q: Read June 17, 2023, editorial from the Wall Street Journal entitled "Biden's Fishy Plan to Breach…
Q: Should the United States allow Mexico to have water from the Rio Grande and the Colorado River, both…
Q: OA. For the structure shown, rank the bond lengths (labeled a, b and c) from shortest to longest.…
Q: Distinguish between withdrawal and consumption of water
Q: Describe the hydrologic cycle
Q: For the following circuit, What is  Vout as a function of R and Id assuming the op-amp is ideal.…
Q: Can you solve for the voltage through the 1k ohm resistor with the diode present. Additionally, can…
Q: Discuss the Civil Rights movement on efforts to gain civil rights by one of the following groups:…
Q: Discuss the ways in which the Thirteenth, Fourteenth, and Fifteenth Amendments provided for the…
Q: How is land use related to water quality and quantity? What are local examples in Connecticut?
Q: 4.1 Basic Rules of Differentiation. 1. Find the derivative of each function. Write answers with…
Q: Link OA is rotating with a counterclockwise angular velocity w = 10 rad/s (ignore the direction…
Q: File Preview Design a capacitor for a special purpose. After graduating from medical school you and…