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 <destination>, it is about <given_distance> miles away. where the destination is the return from the function get_destination
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
Please enter a valid distance between 0 and 100 miles.Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
- Data Generator Most application depends on data. In IoT data is collected/generate by sensors. Since, we do not have access to sensors, we will have to generate data via code. The plotting a sufficient number of these data points (500 in this case) should get the following diagram or something very similar: You will pick a quantity that you would like to simulate (such as temperature, humidity, barometric pressure, customers arriving at a mall, or just with an alternate descriptor) and decide what shape you will emulate. This will guide you in selecting sensible value base lines for your data values. e.g., If you pick inside temperature then normal range will be 18-21oC. Design and build a class that will model your sensor reasonably well. Notice how the peaks do not occur at regular interval, nor are they the same height. Even the squiggles are the same shapes. You will create a class with a single public member (property) that give you a “random” value in your intended range and…arrow_forward2-18 Please answer question. my answers are incorrect, thank you!arrow_forward16 Type the correct answer in the box. Use numerals instead of words. If necessary, use / for the fraction bar. var num2 = 32; var num1 = 12; var rem=num2 % num1; while(rem> 0) { num2 = num1; num1 = rem; rem =num2 9% num1; document.write(num1): The output of the document.write statement at the end of this block is Reset Next m. All rights reserved. 5896arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY