[Tutor] program?

R. Alan Monroe amonroe at columbus.rr.com
Sat Dec 6 17:44:44 EST 2003


>  >>> # Perimeter of a rectangle equals sum of width times two, plus sum
> of lenth times 2.
>  >>> width = 8 #inches
>  >>> length = 1 #foot
>  >>> (width * 2) + (length * 2)
> 18
>  >>> # answer is incorrect, because inches and feet are not same unit.

> How would I be able to fix that?

The easy way:
length = 12 #inches


The hard way:
Have the user enter the length as "1f", then attempt to detect whether
or not their input has an "f" at the end of it - if it does, multiply
it by 12...


Alan




More information about the Tutor mailing list