def windchill(temp, vel):
wc = 35.74 + .6215*temp - (35.75*vel**.16 + .4275*temp*vel**.16)
return wc

def main():
print (" __ __ __Temp /n")
print (" Speed /n")
print ("-20 70 10 0 10 20 30 40 50 60 ")

for x in range (5,55,5):
print x
for y in range (-20,70,10):
chill =windchill(x,y)
print chill + " "


main()

:mad: :cry: :o

Dani AI

Generated

As started and pointed out, the program needs a couple of structural fixes and a few domain checks to produce a sensible wind‑chill table. Key things to watch for: the wind‑chill formula uses Fahrenheit and miles per hour and is only valid for temperatures at or below 50 F and wind speeds above about 3 mph; the last term is added, not subtracted; and the function parameters must be passed in the same order the function expects. Also use meaningful names and format numbers for a neat table instead of concatenating strings and numbers.

A compact, modern approach:

  • Keep the function signature obvious (e.g., temp_f, wind_mph) and validate inputs.
  • Apply the standard formula with the correct sign for the last term.
  • Print a header row, then loop temperatures and speeds in a consistent order so rows/columns match expectations.
  • Format numeric output (one decimal place) and avoid mixing types in print concatenation.

Example implementation (Python 3) that addresses these points:

def windchill(temp_f, wind_mph):
    if wind_mph < 3 or temp_f > 50:
        return temp_f
    return 35.74 + 0.6215*temp_f - 35.75*(wind_mph**0.16) + 0.4275*temp_f*(wind_mph**0.16)

def print_table():
    speeds = range(5, 55, 5)
    temps = range(-20, 70, 10)
    print("Temp\\Speed", end="")
    for s in speeds:
        print(f"{s:8}", end="")
    print()
    for t in temps:
        print(f"{t:9}", end="")
        for s in speeds:
            wc = windchill(t, s)
            print(f"{wc:8.1f}", end="")
        print()

if __name__ == "__main__":
    print_table()

Final tips: test with known cases (e.g., 0 F at 30 mph) to verify output, avoid passing swapped arguments to the function, and when posting code on the forum use the code tag so indentation is preserved (as suggested). For background on the formula and its valid range, consult a reputable reference such as the wind‑chill article on Wikipedia.

Once more, please put your code into code tags to show the right indentation, see:
http://www.daniweb.com/techtalkforums/announcement114-3.html

Most people will not read any of your code unless you do that!

Your first program worked just fine, why did you change it?

This program will give you error, because you are giving it negative windspeeds! Use more meaningful variable names, t and v rather than x and y and you discover your mistakes!

Also newline is \n

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.