Write a program to use the check_input to create a list of valid temperatures and compute their statistics: Create a list, where you will store the "possible" temperatures. Let's say temperatures list. 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. Find the minimum, maximum, and average temperature in the temperatures list and print it to match the example below:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Temperature Statistics

 

Learning Objectives

In this lab, you will

  • Create a function to match the specifications
  • Use the if/else statements to detect a range
  • Use lists to store the results

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, the temperature in Sahara varies from -4 to -10 С. During the day, the temperature varies from 20 to 50 C.

Create a function check_input(temperature) that will return True if the temperature given as input can be from Sahara and False if it is from a broken thermometer (i.e., outside of the expected range).

Steps

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 the temperatures list and print it to match the example below:

Example

input

-10 -20 20 48 21

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.

 

 

def check_input(value):
    """ Define your function here """
    pass

if __name__ == '__main__':
    # Type your code here.

main.py
Load default template...
1 def check_input (value):
""" Define your function here """
3
pass
4
5 if
name
main
':
==
# Type your code here.
Transcribed Image Text:main.py Load default template... 1 def check_input (value): """ Define your function here """ 3 pass 4 5 if name main ': == # Type your code here.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY