On 01/-10/-28163 02:59 PM, Matthew Speltz wrote:
I'm trying to teach myself python and have run across a rather
annoying error. I'm not sure exactly where the fault lies, so please
pardon me for posting too much information, I'm not sure what would be
relevant.
I'm running the Python 3.2 Windows X86-64 MSI Installer found on
http://www.python.org/download
It opens fine, seems to run other scripts fine, but fails when I try
to run my temperature converter script. I have tried uninstalling and
reinstalling Python a couple times, but it fails the exact same way.
I try to leave debugging on in IDLE, but all the windows simply close
and the processes exit. Any ideas on what to try next to fix this?
[code]
#!usr/bin/python
# Filename Temp_converter.py
print('''Temperature converter, by ***** *****.\n'
Please enter the Temperature you wish to convert, followed
by the unit (C or F).''')
while True: #This forces the program to come back to the beginning if
the units end up being entered incorrectly.
raw = input('> ') #prompt for temp
windchill = False #used later, defining now
if raw.endswith('F') or raw.endswith('f'): #Fahrenheit statement
temp = int(raw.strip('Ff ')) #Returns just the numeric value
unit = 'Celsius' #notes what we're converting to
if temp<= 40: #if appropriate, offers to calculate wind chill
windchill = True
tempf = temp #sets tempf for use as the fahrenheit format
for windchill
global tempf
temp = (5/9)*(temp-32) #Converts Temperature
break #operation completed, move to close
elif raw.endswith('C') or raw.endswith('c'): #Celsius statement
temp = int(raw.strip('Cc ')) #Returns just the numberic value
unit = 'Fahrenheit'
temp = (9/5)*temp+32 #Converts Temperature
if temp<= 40: #if appropriate, offers to calculate wind chill
windchill = True
tempf = temp #sets tempf for use as the fahrenheit format
for windchill
global tempf
break #operation completed, move to close
else:
print('Incorrect format, please try again')
print ('Temperature in {0} is {1} .'.format(unit, temp)) #Prints
results from while loop
if windchill is True:
print ('For the wind chill, please enter the average wind speed in mph')
raw = input('> ')
wind = int(raw.strip('mph ')) #in here to force last user input to
a float number, also wind is used in windchill calulation
chill = 35.74 + (.6215 * tempf) - 35.75(wind**.16) + .4275 *
tempf(wind**.16) #formula for wind chill
print ('The windchill for {0} degrees {1} at {2} mph is
{3}'.format(temp, unit, wind, chill))
[/code]
All that information is useful, but you left out the stack trace of the
error message. You say it "fails" but not how.
Run it from a CMD prompt, and carefully paste the entire stack trace of
the error you get. I've no experience with IDLE, and you say it closes
on you anyway. So don't use it. Just run from a command prompt, and
notice what it displays.
DaveA
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor