Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 4 - Selections - Programming Exercises - Page 124: 4.20

Answer

code

Work Step by Step

# 4.20 (Science: wind-chill temperature) Exercise 2.9 gives a formula to compute the # wind-chill temperature. The formula is valid for temperatures in the range # between and 41°F and for wind speed greater than or equal to 2. Write a # program that prompts the user to enter a temperature and a wind speed. The program # displays the wind-chill temperature if the input is valid; otherwise, it displays # a message indicating whether the temperature and/or wind speed is invalid. temp, windSpeed = eval(input("Enter temperature in Fahrenheit and wind speed: ")) if (temp < -58 or temp > 41) or (windSpeed < 2): print("The temperature and/or wind speed is invalid.") else: windChill = 35.74 + 0.6215 * temp - 35.75 * windSpeed ** 0.16 + 0.4275 * temp * windSpeed ** 0.16 print("The wind chill temprature is", format(windChill, "0.2f"))
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.