# windchill
def windchill(t, v):
"""
windchill(t,v) takes a temperature and wind speed and returns the
windchill factor.
t = temperature in Farhenheit
v = wind speed in miles per hour
>>> windchill(5,10)
-9.737344294197483
>>> windchill(20,20)
4.242781599820461
>>> windchill(-10,50)
-45.32064601872968
"""
return 35.74 + 0.6215 * t - 35.75 * v**0.16 + 0.4275 * t * v**0.16
def getuservalue(s):
while True:
try:
val = int(raw_input(s))
return val
except ValueError:
print "Error! - Please enter an integer."
def main():
tmin = getuservalue('Please enter starting temperature in degrees Fahrenheit: ')
tmax = getuservalue('Please enter ending temperature: ')
tinc = getuservalue('Please enter an increment value for temperature: ')
vmin = getuservalue('\nPlease enter a starting wind speed in miles per hour: ')
vmax = getuservalue('Please enter an ending wind speed: ')
vinc = getuservalue('Please enter an increment value for wind speed: ')
# Build a windchill lookup table
print('\n\n')
# output column header
print "T(degF)\t",
for v in range(vmin, vmax+vinc,vinc): # adding increment to the max value to
print v,"mph\t", # ensure we output the max value or greater
print "\n======\t",
for v in range(vmin, vmax+vinc,vinc):
print "======\t",
# print the table
print
for t in range(tmin, tmax+tinc, tinc):
print t,
for v in range(vmin, vmax+vinc, vinc):
print "\t%-4.2f"%(windchill(t,v)),
print
temp = raw_input('[press ENTER to quit]')
if __name__ == "__main__":
import doctest
doctest.testmod()
main()