Difference between revisions of "Wind Chill"
From CompSciWiki
(Completed the Wind chill program.) |
(reworded a sentence in step 4) |
||
(10 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{Template:1010ExtraLabs | {{Template:1010ExtraLabs | ||
|Chapter_TOC=[[Extra Labs]] | |Chapter_TOC=[[Extra Labs]] | ||
− | |Introduction=In Winnipeg , | + | |Introduction=In Winnipeg, the wind can make the temperature '''even''' colder than it is without windchill. Write a program that uses '''input''' to read in an air temperature and a wind speed. Then, use the formula below to calculate and output the windchill. |
:<math>T_{wc}=13.12 + 0.6215 T_a-11.37 V^{0.16} + 0.3965 T_a V^{0.16}\,\!</math> | :<math>T_{wc}=13.12 + 0.6215 T_a-11.37 V^{0.16} + 0.3965 T_a V^{0.16}\,\!</math> | ||
Line 9: | Line 9: | ||
|Body= | |Body= | ||
− | === | + | ===Step 1: Get inputs/outputs needed to solve the problem=== |
− | You will need the following in order to solve this problem. | + | You will need the following variables in order to solve this problem. |
− | + | * location - The location at which you want to calculate the windchill. | |
− | + | * temperatue - The temperature of your desired location | |
− | + | * windSpeed - The windSpeed at your desired location | |
− | + | * input - Used to prompt the user for input | |
− | + | * raw_input - Used to prompt the user for input | |
− | + | * windChill - The calculated wind chill of your desired location | |
− | === | + | ===Step 2: Write the program=== |
{{CodeBlock | {{CodeBlock | ||
Line 42: | Line 42: | ||
}} | }} | ||
− | === | + | ===Step 3: Display the output of the program=== |
{{OutputBlock | {{OutputBlock | ||
Line 54: | Line 54: | ||
}} | }} | ||
− | === | + | ===Step 4: Contrast with windChill program in Program a Day example=== |
− | This Python program | + | This Python program produces the same output as the Java WindChill program in [[Program_a_day|Program-A-Day]], |
− | + | but there are some differences which are described below. | |
− | + | * Python uses x**y as its Math power operator whereas Java uses Math.pow(x,y) | |
− | + | * Python does not perform conversion to other types but Java uses for instance double x = Double.parseDouble(y) to convert y to double data type | |
− | + | * In the print statements, Python specifies the format(%f = float data type) of some variable. | |
}} | }} |
Latest revision as of 05:00, 5 April 2012
COMP 1010 Home > Back to Extra Labs
IntroductionIn Winnipeg, the wind can make the temperature even colder than it is without windchill. Write a program that uses input to read in an air temperature and a wind speed. Then, use the formula below to calculate and output the windchill.
|
---|
Step 1: Get inputs/outputs needed to solve the problem
You will need the following variables in order to solve this problem.
- location - The location at which you want to calculate the windchill.
- temperatue - The temperature of your desired location
- windSpeed - The windSpeed at your desired location
- input - Used to prompt the user for input
- raw_input - Used to prompt the user for input
- windChill - The calculated wind chill of your desired location
Step 2: Write the program
####################################################################### #This program is used to calculate the wind chill of a desired location #input location = raw_input("What is the location?") temperature = input("What is the current temperature in Celsius?") windSpeed = input("What is the wind speed in kms per hour?") #calculate windchill windchill = 13.12 + .6215*temperature- 11.37 * (windSpeed**0.16) + 0.3965 * temperature * (windSpeed ** 0.16) #output print "\n\nLocation: " + location print "Current Temperature: %f" % temperature + " Celsius" print "Wind Speed:%02f " % windSpeed + " km/h" print "Temperature with Windchill: %02f" % windchill print "Programmed by A. Student" print "**End of Program**"
Step 3: Display the output of the program
Location: Winnipeg Current Temperature: -10.0 Celsius Wind Speed: 30.0 km/h Temperature with Windchill: -19.52049803338773 Programmed by A. Student **End of Program**
Step 4: Contrast with windChill program in Program a Day example
This Python program produces the same output as the Java WindChill program in Program-A-Day, but there are some differences which are described below.
- Python uses x**y as its Math power operator whereas Java uses Math.pow(x,y)
- Python does not perform conversion to other types but Java uses for instance double x = Double.parseDouble(y) to convert y to double data type
- In the print statements, Python specifies the format(%f = float data type) of some variable.