View Single Post
  #9 (permalink)  
Old 01-22-2008, 03:48 PM
nolls nolls is offline
Newbie
 
Join Date: Jan 2008
Posts: 18
Rep Power: 3
nolls is on a distinguished road
Default

About the 5th option, I was confused as to how it would exit if I got rid of the last three lines. Then I realized, if option isn't equal to 5 it will run, and if it doesn't (by pressing 5) it would stop. Yeah, I felt pretty stupid after I realized that.

O and after I took out the last three lines the program didn't have the problem again. What would happen though, is that I run press F5 to run it and it would run, but nothing would happen. As soon as I would press enter, the program would start running. Pretty weird huh?

Also, I think I read this in "Beginning Python- From Novice to Professional", the first line of code makes it into an executable? Is this true, if not, how do you?

Ok here is the FINAL calculator program:

Code:
#!/C:Python25/Calc Test.py
print "Welcome to Nolls's Calculator 1.0"
option = 0
while option != 5:
    print "1. addition"
    print "2. subtraction"
    print "3. multiplication"
    print "4. division"
    print "5. exit"
    option = input("Which would you like to do? ")
    if option == 1:
        a = input("First number ")
        print a
        b = input("Plus second number ")
        print b
        print a + b
    elif option == 2:
        a = input("First number ")
        print a
        b = input("Minus second number ")
        print a - b
    elif option == 3:
        a = input("First number ")
        print a
        b = input("Multiplied by second number ")
        print b
        print a * b
    elif option == 4:
        a = input("First number ")
        print a
        b = input("Divided by second number ")
        print b
        print a / b
Reply With Quote