Programming‎ > ‎Mini-Projects‎ > ‎

02 Windchill

Overview

Your first assignment is to write a program that computes the windchill factor for a given temperature and windspeed and prints a well formated table for a range of temperatures and wind speeds. This program will exercise your understanding of

  • functions 
  • mathematical computations
  • looping structures using for loops
  • output formating
  • proper coding structure and style

Details

The National Weather Service computes the windchill index using the following formula:

 
    35.74 + 0.6215 * T - 35.75 * V0.16 + 0.4275 * T * V0.16
 
T is the temperature in degrees Fahrenheit, and V is the windspeed in miles per hour. Write a program that prints a nicely formatted table of windchill values. Rows should represent wind speed from 5 to 50 in 5mph increments, and columns represent temperatures from -20F to 60F in 10 degree increments. Your program must print proper row and column headings.

Version 1

Specifically your program must do the following:

  1. use a function called windchill(T,V) that takes a temperature T and windspeed V and returns the computed windchill factor.
  2. output a well formatted table 
  3. You may only use the def, print, forrange, and round functions.
  4. You may use the .format() method on strings for formatting.

 Sample Output

T(degF)   0 mph   5 mph  10 mph  15 mph  20 mph  25 mph  30 mph  35 mph  40 mph
======= ======= ======= ======= ======= ======= ======= ======= ======= ======= 
    -30   17.09  -45.75  -53.12  -57.82  -61.35  -64.20  -66.61  -68.70  -70.55
    -20   23.31  -34.00  -40.72  -45.01  -48.23  -50.83  -53.03  -54.93  -56.62
    -10   29.53  -22.26  -28.33  -32.21  -35.11  -37.46  -39.45  -41.17  -42.70
      0   35.74  -10.51  -15.93  -19.40  -22.00  -24.09  -25.86  -27.40  -28.77
     10   41.96    1.24   -3.54   -6.59   -8.88  -10.72  -12.28  -13.64  -14.84
     20   48.17   12.98    8.85    6.22    4.24    2.65    1.30    0.13   -0.91
     30   54.39   24.73   21.25   19.03   17.36   16.02   14.88   13.89   13.02


Version 2

Now modify your program to 

  1. Ask the user for start, stop, and increment values for both wind speed and temperature.
  2. Build a customized table, similar to above, but with the wind speeds and temperatures customized to the values entered by the user.
  3. The program must pause and ask the user to press ENTER before quitting.
  4. To the previous allowed functions, you can now also use input.

Version 3

Now modify your program to
  1. Comply with the code structure guidelines required by course.
  2. Include the following doctests to ensure that your windchill function is working properly.
    """
    >>> windchill(5,10)
    -9.737344294197483
    >>> windchill(20,20)
    4.242781599820461
    >>> windchill(-10,50)
    -45.32064601872968
    """