Small program trouble WAS Re: Small proram troble
Rob
uselesspython at yahoo.com
Mon Sep 3 20:11:20 EDT 2001
Ignacio Vazquez-Abrams wrote:
> On 3 Sep 2001, Patio87 wrote:
>
>
>>I have a problem with this simple program but im very new to python and this is
>>the biggest program i have written. Now I think the problem is the while loop
>>but im not sure if someone could take a look at this it would be apprecitaed
>>
>
> Yikes. Here's my fixed version:
>
> ---
And here's my fixed version of the fixed version:
import sys
choice = 0
def print_options():
print "Options:"
print "'1' Print Options"
print "'2' Add numbers"
print "'3' Subtract numbers"
print "'4' Multiply number"
print "'5' Divide number"
print "'6' Exit"
print_options()
while choice != 6:
choice = raw_input("What would thou like to do?")
if choice == "1":
print_options()
elif choice == "2":
add = input("What number would you like to add?")
add2 = input("What other number do you want to add?")
print "The awnser is", add + add2
elif choice == "3":
sub = input("What number do you want to subtract?")
sub2 = input("What 2nd number do you want to subtract?")
print "Your awnser is,", sub + sub2
elif choice == "4":
mul = input("What number do you want to multiply")
mul2 = input("What 2nd number do you want to multiply")
print "Your multiplicated number is", mul * mul2
elif choice == "5":
div = input("What is your dividend?")
div2 = input("What is your numerator?")
print "Your awnser is", div/div2
elif choice == "6":
print "thanks for using my program"
sys.exit()
ooh-this-is-fun-ly,
Rob
--
A {} is a terrible thing to waste.
Useless Python!
http://www.lowerstandard.com/python
More information about the Python-list
mailing list