Question
The UCSB surroundings tour guide! Learning Objectives In this lab, you will Use Boolean operators (and/or/not) to specify a range Use if/elif/else to correctly select
The UCSB surroundings tour guide!
Learning Objectives
In this lab, you will
- Use Boolean operators (and/or/not) to specify a range
- Use if/elif/else to correctly select a place and produce the specified output
Instructions
Main Idea
The UCSB surroundings tour guide!
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 know 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 program that returns one of the interesting places, available 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:
[0 - 2]: "Lake Los Carneros Park" (2 - 7]: "Elings Park" (7 - 11]: "Gibraltar Rock" (11 - 20]: "Carpinteria State Beach" (20 - 30]: "Oxnard" (30 - 100]: "Los Angeles"Here, the open parenthesis ( , indicates that we are not including this value, and the square brackets [, ] mean that the value is included in the range.
Steps
- Input (read) a valid integer and store it as the given distance.
- If the given distance is outside the range of [0 - 100], display the message Please enter a valid distance between 0 and 100 miles..
- Write a function get_destination that takes the given distance as a parameter and returns the destination
- Call the function get_destination, when the given distance is within the [0 - 100] range)
- Print the message How about visiting
Examples
Input
8Output
How about visiting Gibraltar Rock, it is about 8 miles away.Input
30Output
How about visiting Oxnard, it is about 30 miles away.Input
120Output
Please enter a valid distance between 0 and 100 miles.Input
-100Output
The UCSB surroundings tour guide!
Learning Objectives
In this lab, you will
- Use Boolean operators (and/or/not) to specify a range
- Use if/elif/else to correctly select a place and produce the specified output
Instructions
Main Idea
The UCSB surroundings tour guide!
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 know 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 program that returns one of the interesting places, available 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:
[0 - 2]: "Lake Los Carneros Park" (2 - 7]: "Elings Park" (7 - 11]: "Gibraltar Rock" (11 - 20]: "Carpinteria State Beach" (20 - 30]: "Oxnard" (30 - 100]: "Los Angeles"Here, the open parenthesis ( , indicates that we are not including this value, and the square brackets [, ] mean that the value is included in the range.
Steps
- Input (read) a valid integer and store it as the given distance.
- If the given distance is outside the range of [0 - 100], display the message Please enter a valid distance between 0 and 100 miles..
- Write a function get_destination that takes the given distance as a parameter and returns the destination
- Call the function get_destination, when the given distance is within the [0 - 100] range)
- Print the message How about visiting
Examples
Input
8Output
How about visiting Gibraltar Rock, it is about 8 miles away.Input
30Output
How about visiting Oxnard, it is about 30 miles away.Input
120Output
Please enter a valid distance between 0 and 100 miles.Input
-100Output
Step by Step Solution
There are 3 Steps involved in it
Step: 1
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-text-image.webp)
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-subtext-image.webp)
Step: 3
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-subtext-image.webp)
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started