Feet and inches

todpose at hotmail.com todpose at hotmail.com
Wed Feb 4 20:28:06 EST 2009


I'm trying to get Python to say:
 
Enter the height (in metres):
 
and convert whatever value to feet and inches. I've done this part as you can see below, but how can I terminate the program when user inputs a height less than 1/2 inch?
How can I also take into account all the cases that need an exception?
 
 
metres = float(raw_input("Enter the height (in metres): "))total_inches = 39.37 * metresfeet = int(total_inches/12)inches = int(round(total_inches - feet*12))if feet>=1:    print "It is " + str(feet) + " feet " + str(inches) + ' inches high.'if feet<1 and inches<0.5:    print "Error."
_________________________________________________________________
Windows Live Messenger. Multitasking at its finest.
http://www.microsoft.com/windows/windowslive/messenger.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090204/f16924c6/attachment.html>


More information about the Python-list mailing list