[Tutor] Converter

bob gailer bgailer at alum.rpi.edu
Thu Mar 20 02:18:47 CET 2008

wackedd at mac.com wrote:
> print "Converter"
> number = 2.5
> n = int(raw_input("Insert Feet Amount"))
> while n > 0:
>         print n, "Feet is"
>         print n*12, "inches"
>         print n*30, "centimeters"
> print
> Currently this is what I am working with.
> 2 problems I am facing.
> 1. When I run the script and type in the amount of feet it calculates it OVER AND OVER.

I'd like to introduce you to the concept known as "desk checking". 
Pretend you are the computer executing this program. Mentally (or even 
better on paper) execute each statement in the order that the computer 
would. Write down the values of variables as they change. Especially pay 
attention to the value of n. Also ask of what use is the variable numnber?
> [snip]
> 2. Currently this script only works for the amount of feet, is their a way to have it choose feet, inches, to convert into whatever, without having to right the script over and over, and all in different programs. 

I don't understand this part of the question.
> Maybe using if raw_input = feet then do this equation. I am coding in pure Python on my mac, so please nothing in C as  have been some answers I have received.

Bob Gailer
919-636-4239 Chapel Hill, NC

More information about the Tutor mailing list