4.19 LAB: 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 , it is about miles away. where the destination is the return from the function get_destination Examples Input 8 Output How about visiting Gibraltar Rock, it is about 8 miles away. Input 30 Output How about visiting Oxnard, it is about 30 miles away. Input 120 Output Please enter a valid distance between 0 and 100 miles. Input -100 Output Please enter a valid distance between 0 and 100 miles.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

4.19 LAB: 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

  1. Input (read) a valid integer and store it as the given distance.
  2. If the given distance is outside the range of [0 - 100], display the message Please enter a valid distance between 0 and 100 miles..
  3. Write a function get_destination that takes the given distance as a parameter and returns the destination
  4. Call the function get_destination, when the given distance is within the [0 - 100] range)
  5. Print the message How about visiting <destination>, it is about <given_distance> miles away. where the destination is the return from the function get_destination

Examples

Input

8

Output

How about visiting Gibraltar Rock, it is about 8 miles away.

Input

30

Output

How about visiting Oxnard, it is about 30 miles away.

Input

120

Output

Please enter a valid distance between 0 and 100 miles.

Input

-100

Output

Please enter a valid distance between 0 and 100 miles.
main.py
Load default template...
1 def get_destination(miles):
2
3
Type the function logic here
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"
4
5
8
9
10
11
12
13
14 if
name
main ":
==
15
'Type your code here'''|
Transcribed Image Text:main.py Load default template... 1 def get_destination(miles): 2 3 Type the function logic here 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" 4 5 8 9 10 11 12 13 14 if name main ": == 15 'Type your code here'''|
mput
Your output
Please enter a valid distance between 0 and 100 miles.
10: Compare output ^
1/1
Input
250
Your output
Please enter a valid distance between 0 and 100 miles.
11: Unit test ^
0/1
Transcribed Image Text:mput Your output Please enter a valid distance between 0 and 100 miles. 10: Compare output ^ 1/1 Input 250 Your output Please enter a valid distance between 0 and 100 miles. 11: Unit test ^ 0/1
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
Types of Function
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education