954,549 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Why Is It Still Not Running...Help...Due In 5hrs..

THIS WINDCHILL TABLE PROGRAM IS RUNNING, BUT THE NUMBERS IS STILL NOT LINING UP STRAIGHT..WHY, CAN YOU PLEASE HELP ME..THANKS


HERE IS THE PROGRAM BEFORE I RUN IT..

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



def main():
    print (" __ __ __               Temperature \n")
    print ("Speed \n")
    print (" 1 -20 70 10 0 10 20 30 40 50 60 ")
    



    for x in range(5, 55, 5):
        print x
        for y in range (60, -30, -10):
            chill = windchill(x,y)
            print str(int(chill)) + " ",
       



main()

AND HERE IS THE RESULTS AFTER I RUN IT...SEE THE NUMBERS IS NOT LINE UP STRAIGHT..

__ __ __               Temperature 

Speed 

 1 -20 70 10 0 10 20 30 40 50 60 
5
59  48  36  24  12  1  -10  -22  -34  10
58  46  33  21  8  -3  -15  -28  -40  15
57  44  31  19  6  -6  -19  -32  -45  20
56  43  30  17  4  -8  -21  -35  -48  25
56  42  29  16  2  -10  -24  -37  -50  30
55  42  28  14  1  -12  -25  -39  -53  35
55  41  27  13  0  -13  -27  -41  -54  40
54  40  26  13  0  -14  -28  -42  -56  45
54  40  26  12  -1  -15  -29  -44  -58  50
54  39  25  11  -2  -16  -31  -45  -59

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

butterflyTee
Light Poster
43 posts since Feb 2006
Reputation Points: 10
Solved Threads: 0
 

Hi butterflyTee,

Please check your PM inbox.

To get the numbers to line up, you are going to need to use a formatting modifier to your print statement. Try something like:

print str("%3d" %int(chill))+" ",


instead of the print statement you have in your nested for-loop. This should space the numbers properly.

G-Do
Junior Poster
147 posts since Jun 2005
Reputation Points: 41
Solved Threads: 31
 

thank you, it did work

butterflyTee
Light Poster
43 posts since Feb 2006
Reputation Points: 10
Solved Threads: 0
 

Try
print '%3s ' %(str(int(chill))),

bucodi
Newbie Poster
8 posts since Dec 2005
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You