DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Python (http://www.daniweb.com/forums/forum114.html)
-   -   Did I do the windchill index correctly.Due in 18hrs.Is there other ways to write this (http://www.daniweb.com/forums/thread43522.html)

butterflyTee Apr 17th, 2006 7:37 pm
Did I do the windchill index correctly.Due in 18hrs.Is there other ways to write this
 
#   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

alc6379 Apr 17th, 2006 9:08 pm
Re: Did I do the windchill index correctly.Due in 18hrs.Is there other ways to write
 
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.

butterflyTee Apr 18th, 2006 11:21 am
Re: Did I do the windchill index correctly.Due in 18hrs.Is there other ways to write
 
is there other to write this program?

butterflyTee Apr 19th, 2006 1:30 pm
Re: Did I do the windchill index correctly.Due in 18hrs.Is there other ways to write this
 
I WROTE 2 PROGRAMS FOR WINDCHILL, AND IT STILL NOT RUNNING CORRECTLY. I TRIED EVERYTHING.


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

alc6379 Apr 19th, 2006 7:26 pm
Re: Did I do the windchill index correctly.Due in 18hrs.Is there other ways to write
 
Quote:

Originally Posted by butterflyTee
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?


All times are GMT -4. The time now is 8:44 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC