Question

PythonThe program first prompts for and reads in temperatures (all integers), until a line with no characters in received. It compuEnter wind speed: 30 Enter wind speed: 10 Enter wind speed: 50 Enter wind speed: 20 Enter wind speed: 1 Enter current humidit

  1. Testing

    1. a) The temperature readings are correctly handled using a while loop and the output is correct

    2. b) The wind speed readings are correctly handled using a while loop and the output is correct

    3. c) The humidity readings are correctly handled using a while loop and the output is correct

    4. d) Works correctly overall

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Screenshot of the code used:

PC - 0 ě x a temp_speed_humidity 4: Run I 1: Project oo vane wn File Edit View Navigate Code Refactor Run Tools VCS Window HePC Tools VCS Window Help Python_Mosh [H:\Python Projects\Python_Mosh] - ...temp_speed_humidity.py - PyCharm - File Edit View

The output obtained:

Run: → IR temp_speed_humidity X H:\Python Projects Python_Mosh\venv\Scripts Enter temperature: 30 Enter temperature: 40 Enter

t IP: 71 temp_speed_humidity X H:\Python Projects\Python_Mosh\venv\Scripts\python Enter temperature: Enter wind speed: -1 Ent

The code used:

temperature_list = list()    # this will store the temperature entered by the user.
while True:
    temp = input("Enter temperature: ")
    if len(temp) != 0:
        temperature_list.append(int(temp))
    else:
        break

wind_speed_list = list()   # this will store the wind speed entered by the user.
while True:
    speed = int(input("Enter wind speed: "))
    if speed < 0:
        break
    else:
        wind_speed_list.append(speed)

current_humidity = -1
humidity = int(input("Enter the current humidity(0-100): "))
while 0 <= humidity <= 100:
    current_humidity = humidity
    humidity = int(input("Enter the current humidity: "))

# checking for the no info criteria and printing the output to the console
if len(temperature_list) > 0:
    average = sum(temperature_list) // len(temperature_list)
    print("Average temperature", average)
else:
    print("Average temperature No info on temperature")

if len(wind_speed_list) > 0:
    print("Maximum wind speed", max(wind_speed_list))
else:
    print("Maximum wind speed No info on wind speed")

if current_humidity == -1:
    print("Current humidity No info on humidity")
else:
    print("Current humidity", current_humidity)

I hope you like the solution. In case of any doubts regarding the solution feel free to ask it in the comment section. If you like the solution please give a thumbs up.

Add a comment
Know the answer?
Add Answer to:
Python Testing a) The temperature readings are correctly handled using a while loop and the output...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python Code Write a program using functions and mainline logic which prompts the user to enter...

    Python Code Write a program using functions and mainline logic which prompts the user to enter a number. The number must be at least 5 and at most 20. (In other words, between 5 and 20, inclusive.) The program then generates that number of random integers and stores them in a list. The random integers should range from 0 to 100. (You can use a wider range if you want, but the lower end of the range must be at...

  • Hi im having trouble with this homework question. Can someone show me how to do this in C++ with all the steps? Weather Analysis WeatherAnalyzer - New Day Data 2- Good Days 3- Summary 0- Exit Step 0:...

    Hi im having trouble with this homework question. Can someone show me how to do this in C++ with all the steps? Weather Analysis WeatherAnalyzer - New Day Data 2- Good Days 3- Summary 0- Exit Step 0: You can get the sample file from this link: Each row in the text file represent weather measurement of a day. For each day, the file contains the temperature (first column), humidity (second column) and the wind (third column) values emp 70...

  • NOTE: Write the Program in python as mentioned below and use while loop and flags as...

    NOTE: Write the Program in python as mentioned below and use while loop and flags as necessary. And please write the code following the program description given below. Directions: Read the program description below carefully. All requirements must be met by your program to receive full credit. Thus, pay particular attention to input and output requirements, structural requirements, and so on. Furthermore, code that contains syntax errors will not receive any credit, so be sure that your code interprets correctly...

  • NOTE: Write the Program in python as mentioned below and use while loop and flags as...

    NOTE: Write the Program in python as mentioned below and use while loop and flags as necessary. And please write the code following the program description given below. DON'T use Function concept or any other concept except while loop,if-else. Directions: Read the program description below carefully. All requirements must be met by your program to receive full credit. Thus, pay particular attention to input and output requirements, structural requirements, and so on. Furthermore, code that contains syntax errors will not...

  • Finish the following program which adds up all integers from 0 to the user's given number inclusively using a While Loop

    // Finish the following program which adds up all integers from 0 to// the user's given number inclusively using a While Loop. The total should be// assigned to the variable 'total'.#includeusing namespace std;int main() {int number;int total = 0;int counter = 0; //initialize the variable// user enters a numbercout << "Enter a positive integer to find the summation of ";cout << "all numbers from 0 to the given number up to 100." << endl;cin >> number;// check for invalid user...

  • In this assignment you will be implementing a weather forecaster. It involves writing 3 different classes...

    In this assignment you will be implementing a weather forecaster. It involves writing 3 different classes plus a driver program. It is recommended that you write one class at a time and then write a driver (tester) program to ensure that it works before putting everything together. Alternately, you can use the Interactions tab of JGRASP to test some of the early classes. This is discussed in the next few pages. The Season Class The first, shortest, and easiest class...

  • Using Python Version 1. Write a program that uses a "while" loop to print the first...

    Using Python Version 1. Write a program that uses a "while" loop to print the first 10 positive integers and to compute their sum. Print the sum after it is computed. Do the same with a "for" loop. Version 2. Write a program to approximate the square root of a number. Recall that the square root of a number x is a number r such that r*r = x. Newton discovered that if one initial estimate of r is z...

  • Write a program in C++ that gives the temperature of earth at a depth. It must...

    Write a program in C++ that gives the temperature of earth at a depth. It must be in C++ and follow the information below: Problem description Write a program to take a depth in kilometers inside the earth as input data; calculate and display the temperature at this depth in both degrees Celsius and degree Fahrenheit. The formulas are: Celsius temperature at depth in km: celsius = 10 x depth(km) + 20 Convert celsius to fahrenheit: fahrenheit = 1.8 x...

  • This is a python matplotlib question. So it would be great if you could show me...

    This is a python matplotlib question. So it would be great if you could show me in python method. I have this loadtxt that asked to plot histogram of wind gusts(column 3) that lie in direction angle(column 2) from min angle to max angle inclusively. I don't know how to include min_angle and max_angle into my codes. Histogram of wind gust speeds As before the file akaroawindgusts.txt contains hourly maximum wind gusts speeds at the Akaroa Electronic weather station (EW)...

  • SOLVE ALL THE 3 questions using the properties of OPERATIONAL AMPLIFIER AND BJTs. Problem 1 10...

    SOLVE ALL THE 3 questions using the properties of OPERATIONAL AMPLIFIER AND BJTs. Problem 1 10 Marks A humidity sensor produces linear output voltage in the range of 0 V to 10 mV for humidity levels of 0 % to 100 % respectively. You are required to design the inverting op-amp circuit to achieve the voltage gain of 1000. Op-amp feed-back current should be 0.2 mA when op-amp output is at maximum. Solution: Problem 2 We discussed the summing circuit...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT