Answered step by step
Verified Expert Solution
Question
1 Approved Answer
debug based on the errors reported python We assume that students want to spend their free time doing a little bit of sightseeing, and want
debug based on the errors reported
We assume that students want to spend their free time doing a little bit of sightseeing, and want to know when they can go if they krow the distance that they can walk in miles. Since we do not really know where the user is, the result will not be very accurate. Create a function that returns one of the interesting places avallable within a given distance in miles. (Some users do not like to do too much walking)) Return the corresponding trip destination based on the value of the user input using the following guidelines: (021="IakeLosCarneroaRark"(271"ElingsPark"(711)="GibraltarRook"(1120):"CarpinteriastateBeach"(2030):"Oxnard"(301001;"LosAngeles" Here, the open parenthesis ( indicates that we are not including this value, and the square brackets l/ mean that the value is included in the range. Function Algorithm 1. Write a function get_dest ination() that takes the given distance as a parameter and returns the string with destination 2. Check if the input value (the given distance) is a valid integer. If it is not an integer, return 1 to indicate an error. 3. Otherwise, return the destination, corresponding to the given distance. The main program 1. Get the user input for the distance. 2. If the given distance is within the [0100] range, call the function get_destination(). 1. Print the message How about visiting ? It is about > is the value returned from the function get dest ination () 2 if the given distance is within the [0100] range call the function get_destination() 1. Print the message How about visiting edestinations? It is about egiven_distancer miles away. where the sdest inat ions is the value retumed from the function get dest inat ion() 2 Otherwise, onint You provided an invalid distance that is not between 0 and 1as miles. Examples Input Outpit Hok about vigiting Gibraltas Rock? te is about 8 miles away. input 30 Output How about vifftifg oxnard? it is about 30 miles day. Input 320 Output 100 Qutput You provided an invalid diatance that in not between 0 and 100 mileg. Hints. - you can check the type of an lnput parameter by using the type () function. Tracebock (meat recent call last): F41e "main.py", Hine 25, in conodule? print ("How about vialting "+atr (get_destination(miles)) +" It is about " ittr(milen)+" = File "main, py", 11ne 14, in get_destination retarn ren Ui-boundlocalError: loeal variable 'res' referenced betore assignnent Input Your output Yourprogram produced no output Expectedoutput You provided an Invalid distance that ia not between 0 and 100 miles. Traceback (most recent call last): F11e "main.py", 1ine 25, in Gimodules print("How about visiting "tstr (get_destination(miles)) +" ? It is about "+atr(miles) +" a File "main.py", 1ine 14, in get destination return res UnboundLocalError: local variable 'res' referenced before assignrent python
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