SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Y Daniel Lang
Chapter:
Programming
Exercise:
Programming Excercises
Question:9 | ISBN:978013274719 | Edition: 6

Question

(Science: wind-chill temperature) How cold is it outside? The temperature alone is not enough to provide the answer. Other factors including wind speed, relative humidity, and sunshine play important roles in determining coldness outside. In 2001, the National Weather Service (NWS) implemented the new wind-chill temperature to measure the coldness using temperature and wind speed. The formula is given as follows: where is the outside temperature measured in degrees Fahrenheit and v is the speed measured in miles per hour. is the wind-chill temperature. The formula cannot be used for wind speeds below 2 mph or for temperatures below or above 41°F. Write a program that prompts the user to enter a temperature between and 41°F and a wind speed greater than or equal to 2 and displays the wind-chill temperature.

Here is a sample run: -58F -58F twc ta twc = 35.74 + 0.6215ta - 35.75v0.16 + 0.4275tav0.16 prompt the user to enter the amount of water in kilograms and the initial and final temperatures of the water.

The formula to compute the energy is Q = M * (finalTemperature – initialTemperature) * 4184

where M is the weight of water in kilograms, temperatures are in degrees Celsius, and energy Q is measured in joules. Here is a sample run:

Enter the temperature in Fahrenheit between -58 and 41: 5.3

Enter the wind speed in miles per hour: 6

The wind chill index is -5.56707 

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

import math
print("Enter the temperature in Fahrenheit between -58ºF and 41ºF: ")
temperature = float(input())
print("Enter the wind speed (>= 2) in miles per hour: ")
speed = float(input())
#Compute the wind chill index
windChill = float( (35.74 + 0.6215 * temperature -35.75 * math.pow(speed, .16) +0.4275 * temperature * math.pow(speed, 0.16)))
#Display result
print("The wind chill index is {:.3f} ".format(windChill))

Output:

Enter the temperature in Fahrenheit between -58ºF and 41ºF: 
5.3
Enter the wind speed (>= 2) in miles per hour: 
6
The wind chill index is -5.567 
 

0 0

Discussions

Post the discussion to improve the above solution.