• Create a function to match the specifications • Use the if/else statements to detect a range • Use lists to store the results • Write a program to get the user input and call the custom function and produce the desired output Instructions Sahara desert explorers call us for help! They want to know some statistics about the temperature in Sahara, but sometimes their thermometer fails to record the proper temperature. Help them to find which temperature is from correct recordings and which is broken and calculate statistics on given data. During the night, temperature in Sahara varies from -4 to -10 C. During the day, the temperature varies from 20 to 50 C. Create a function check_input(temperature) that will return True if this temperature can be from Sahara and False if it is from a broken thermometer (i.e., outside of the expected range). Write a program to use the check_input to create a list of valid temperatures and compute their statistics: 1. Create a list, where you will store the "possible" temperatures. Let's say temperatures list. 2. Input five numbers one by one (in this case measurement is an integer, but great that you thought about what type to convert!). For each value, check it with your function and if the function tells that it is the possible temperature for Sahara - add this value to the temperatures list. 3. Find the minimum, maximum, and average temperature in temperatures and print it to match the example below: Example input -10 -20 20 48 21 Example Output The minimum value is -10, the maximum value is 48, the average value is 19.75. Hints! If you wrote the code to work with one input value (including reading it) you can copy-paste it 5 times. Soo we will learn how to do it easier and simpler. • To calculate the minimum and maximum search for the function that we've learned in the List section. For average think about sum and len functions. • Average of some values is the sum of this values, divided by the number of values. Troubleshooting If you are getting an error "TypeError: 'int' object is not subscriptable", check that your function is expecting a single value as an input.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 20PE
icon
Related questions
Question
100%

Python:

Getting a syntax error. Please advise on how to solve this problem. Needs to match the example output.

• Create a function to match the specifications
Use the if/else statements to detect a range
• Use lists to store the results
• Write a program to get the user input and call the custom function and produce the desired output
Instructions
Sahara desert explorers call us for help! They want to know some statistics about the temperature in Sahara,
but sometimes their thermometer fails to record the proper temperature. Help them to find which temperature
is from correct recordings and which is broken and calculate statistics on given data.
During the night, temperature in Sahara varies from -4 to -10 C. During the day, the temperature varies from 20
to 50 C.
Create a function check_input(temperature) that will return True if this temperature can be from Sahara
and False if it is from a broken thermometer (i.e., outside of the expected range).
Write a program to use the check_input to create a list of valid temperatures and compute their statistics:
1. Create a list, where you will store the "possible" temperatures. Let's say temperatures list.
2. Input five numbers one by one (in this case measurement is an integer, but great that you thought about
what type to convert!). For each value, check it with your function and if the function tells that it is the
possible temperature for Sahara - add this value to the temperatures list.
3. Find the minimum, maximum, and average temperature in temperatures and print it to match the
example below:
Example input
-10
-20
20
48
21
Example Output
The minimum value is -10,
the maximum value is 48,
the average value is 19.75.
Hints!
• If you wrote the code to work with one input value (including reading it) you can copy-paste it 5 times. Soon
we will learn how to do it easier and simpler.
• To calculate the minimum and maximum search for the function that we've learned in the List section. For
average think about sum and len functions.
• Average of some values is the sum of this values, divided by the number of values.
Troubleshooting
• If you are getting an error "TypeError: 'int' object is not subscriptable", check that your
function is expecting a single value as an input.
Transcribed Image Text:• Create a function to match the specifications Use the if/else statements to detect a range • Use lists to store the results • Write a program to get the user input and call the custom function and produce the desired output Instructions Sahara desert explorers call us for help! They want to know some statistics about the temperature in Sahara, but sometimes their thermometer fails to record the proper temperature. Help them to find which temperature is from correct recordings and which is broken and calculate statistics on given data. During the night, temperature in Sahara varies from -4 to -10 C. During the day, the temperature varies from 20 to 50 C. Create a function check_input(temperature) that will return True if this temperature can be from Sahara and False if it is from a broken thermometer (i.e., outside of the expected range). Write a program to use the check_input to create a list of valid temperatures and compute their statistics: 1. Create a list, where you will store the "possible" temperatures. Let's say temperatures list. 2. Input five numbers one by one (in this case measurement is an integer, but great that you thought about what type to convert!). For each value, check it with your function and if the function tells that it is the possible temperature for Sahara - add this value to the temperatures list. 3. Find the minimum, maximum, and average temperature in temperatures and print it to match the example below: Example input -10 -20 20 48 21 Example Output The minimum value is -10, the maximum value is 48, the average value is 19.75. Hints! • If you wrote the code to work with one input value (including reading it) you can copy-paste it 5 times. Soon we will learn how to do it easier and simpler. • To calculate the minimum and maximum search for the function that we've learned in the List section. For average think about sum and len functions. • Average of some values is the sum of this values, divided by the number of values. Troubleshooting • If you are getting an error "TypeError: 'int' object is not subscriptable", check that your function is expecting a single value as an input.
1 def check_input(temperture):
if temperature>=-10 and temperature <=-4 or temperature >=20 and temperture<=50:
2
return True
else:
return False
6.
7 if
name
main_':
==
8
total-e
count=0
for i in range (1,6):
temperature-float(input())
if check_input (temperature):
total-total+temperature
count=count+1
if count==1:
10
11
12
13
14
15
maximum-temperature
minimum=temperature
elif temperature<minimum:
minimum=temperature
elif temperature>maximum:
maximum=temperature
else:
16
17
18
19
20
21
22
23
print("")
print("The minimum value is {},".format (minimum)
print("the maximum value is {},".format(maximum)
print("the average value is {}.".format(total/count)
24
25
26
27
Transcribed Image Text:1 def check_input(temperture): if temperature>=-10 and temperature <=-4 or temperature >=20 and temperture<=50: 2 return True else: return False 6. 7 if name main_': == 8 total-e count=0 for i in range (1,6): temperature-float(input()) if check_input (temperature): total-total+temperature count=count+1 if count==1: 10 11 12 13 14 15 maximum-temperature minimum=temperature elif temperature<minimum: minimum=temperature elif temperature>maximum: maximum=temperature else: 16 17 18 19 20 21 22 23 print("") print("The minimum value is {},".format (minimum) print("the maximum value is {},".format(maximum) print("the average value is {}.".format(total/count) 24 25 26 27
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Datatypes
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr