#   windchill.py
#   tpm
#   A program that prints a nicely formatted table of windchill values.  


from math import *

def windchill(t, v):
    c = 35.74 + (0.6215 * t) - (35.75 * v ** .16) + (.4275 * t * v ** .16)
    return c

def main():
    print "MPH:",
    for k in range (-20, 70, 10):
        print "%3d" %k,
    print
    print "_" * 44
    for velocity in range (5, 55, 5):
        print "%3d" %velocity,
        for temp in range (-20, 70, 10):
            chill = windchill(temp, velocity)
            print "%3d" %round(chill),
        print

    main()

:o

Assuming the formula is right, looks basically fine to me. Just be sure to remove the spaces from the main() subroutine you call at the end, there. Good Job!

A handy tip:
Be sure to place [code][/code] tags around your code. It's especially important with Python, because the spaces actually are part of the code structure.

Edited 3 Years Ago by diafol: fixed formatting

I WROTE 2 PROGRAMS FOR WINDCHILL, AND IT STILL NOT RUNNING CORRECTLY. I TRIED EVERYTHING.


:mad: :evil: :cry: :o :sad: :(

I WROTE 2 PROGRAMS FOR WINDCHILL, AND IT STILL NOT RUNNING CORRECTLY. I TRIED EVERYTHING.


:mad: :evil: :cry: :o :sad: :(

Um...

I just said it worked fine on my machine. What is the problem? What errors is the interpreter throwing?

This question has already been answered. Start a new discussion instead.