Python ProgrammingPython Programming

Calculate the Wind Chill Index (WCI)

Develop a program that reads the air temperature and wind speed from the user. Once these values have been read your program should display the wind chill index rounded to the closest integer.[In 2001, Canada, the United Kingdom and the United States adopted the following formula for computing the wind chill index.]
WCI = 13.12 + 0.6215Ta − 11.37V0.16 + 0.3965TaV0.16
Ta is the air temperature in degrees Celsius and V is the wind speed in kilometers per hour.
##
#Python's program to calculate the Wind Chill Index (WCI)
#The wind chill index is only considered valid for temperatures less than or
#equal to 10 degrees Celsius and wind speeds exceeding 4.8 kilometers per hour.
##

#Define the constants
WINDCHILL_OFFSET	= 13.12
WINDCHILL_FACTOR1	= 0.6215
WINDCHILL_FACTOR2	= -11.37	
WINDCHILL_FACTOR3	= 0.3965
WINDCHILL_EXP		= 0.16


#Read the inputs from user air temperature and wind speed
temp	= float(input("Enter the air temperature in (degrees Celsius): "))
speed	= float(input("Enter the wind speed (kilometer per hour): "))

#Calculate the WCI
wci 	= WINDCHILL_OFFSET + (WINDCHILL_FACTOR1 * temp) + (WINDCHILL_FACTOR2 * speed ** WINDCHILL_EXP) + (WINDCHILL_FACTOR3 * temp * speed ** WINDCHILL_EXP)

#Display the result
print("Your Wind Chill Index ","%d"%(wci))
Sample output of above program.
C:\Python\programs>python program14.py
Enter the air temperature in (degrees Celsius): 9.9
Enter the wind speed (kilometer per hour): 4.6
Your Wind Chill Index 9

C:\Python\programs>python program14.py
Enter the air temperature in (degrees Celsius): 10
Enter the wind speed (kilometer per hour): 4.8
Your Wind Chill Index 9

C:\Python\programs>python program14.py
Enter the air temperature in (degrees Celsius): 7
Enter the wind speed (kilometer per hour): 4
Your Wind Chill Index 6

#The wind chill index is only considered valid for temperatures less than or equal to 10 degrees Celsius and wind speeds exceeding 4.8 kilometers per hour.#