Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Lab Scenario: 1. You are given a list containing the location and the name of the wonders of the world. 2. The program will ask
Lab Scenario: 1. You are given a list containing the location and the name of the wonders of the world. 2. The program will ask user for a particular location or name of a wonder, or to press enter to receive a hint. 3. If the user requests a hint, a message is displayed providing only the location of the 7 wonders, and the program prompts the user again to enter the wonder name this time. 4. It will run through the list to search for the location/wonder name provided by the user. 5. The list is defined as follows: a. Each item of the list is a string. b. Location and wonder are separated by a colon (' :). c. You need to separate the location and the name of the wonder by (':'). Hint: Remember how you split a string? 6. If the location is found it will display the wonder located at the given location. 7. Similarly, the user could have entered a wonder name, and if the wonder is found, its location is displayed. 8. If the user input is not among the locations/wonders, the program should display the error message as: "Wrong input, the program ends here ". 9. For this lab, you are expected to use for loop to iterate through each item in the list. The program needs to be case sensitive. For example: user can enter the name in all lowercase but the program will still find the name of the wonder if present in the list. Hint: string.lower() and string.upper() are two methods that can be used. 10. Seven wonders name in the list, shown below is also provided in your template file. seven_wonders = ["China:Great wall", "Jordan:Petra", "Brazil:Christ the Redeemer", "Peru: Machu Picchu", "Mexico:Chichen Itza", "India:TajMahal", "Italy:Colosseum"] 11. Test the application by considering some possible I/O Pseudocode: 1. Initialize the list of seven wonders 2. Initialize a variable named 'found' and define it to be False at the beginning. 3. Initialize a variable named 'hint' and define it to be zero at the beginning. 4. Prompt user to enter the location/wonder or press enter for a hint. 5. Check to see whether a hint is requested. 6. If so, display the 7 locations and prompt the user again for an input. 7. Reset hint to 1 . 8. Start for loop to iterate over the list items. 9. If location is present in the list, and the hint variable is 0 10. Print wonder and its Location 11. Reset 'flag' variable to be True 12. If wonder is present in the list 13. Print wonder and its Location 14. Reset 'flag' variable to be True 15. If 'flag' variable is False 16. Print error message Sample I/O: (Sample run 1) Enter location or name of a wonder of the world. If you need a hint press Enter: The 7 wonders of the world are in China, Jordan, Brazil, Peru,Mexico, India, and Italy. Enter the name of a wonder now: Brazil Incorrect entry. The program ends here. (Sample run 2) Enter location or name of a wonder of the world. If you need a hint press Enter: The 7 wonders of the world are in China, Jordan, Brazil, Peru,Mexico, India, and Italy. Enter the name of a wonder now:Colosseum Correct! Colosseum is located in Italy (Sample run 3) Enter location or name of a wonder of the world. If you need a hint press Enter:china Correct! Great wall is located in China (Sample run 4) Enter location or name of a wonder of the world. If you need a hint press Enter:Colosseum Correct! Colosseum is located in Italy
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started