Calculating Wind Chill Factor(WCF) or Wind Chill Index(WCI) in Python Program

PythonServer Side ProgrammingProgramming

In this tutorial, we are going to learn how to calculate Wind Chill Index in Python. We have the formula to calculate the WCI and it's straightforward. We are going to use the following formula to calculate the WCI.

Twc(WCI) = 13.12 + 0.6215Ta – 11.37v+0.16 + 0.3965Tav+0.16

where

Twc = Wind Chill Index (Based on Celsius temperature scale)

Ta = Air Temperature (in degree Celsius)

v = Wind Speed (in miles per hour)

We are going to use the math module function wherever we need them. Using the math module function decreases the execution time of a program.

Follow the below steps to complete the program.

  • Import the math module

  • Initialize the required values.

  • Calculate the WCI using the above formula.

Example

See the code below if you find it difficult.

 Live Demo

# importing the module
import math
# writing function to reuse whenever we want
def wind_chill_index(temperature, wind_speed):
   return 13.12 + 0.6215 * temperature - 11.37 * math.pow(wind_speed, 0.16) + 0.3965 * temperature * math.pow(wind_speed, 0.16)
# calculating the WCI
print(wind_chill_index(35, 75))
print(wind_chill_index(40, 125))

Output

If you execute the above code, then you will get the following result.

39.875733177821786
47.7019177629149

Conclusion

You can break the formula into multiple steps for calculation. If you have any doubts in the tutorial, mention them in the comment section.

raja
Published on 24-Apr-2020 16:09:33
Advertisements