Nov-08-2016, 02:14 PM (This post was last modified: Nov-08-2016, 03:29 PM by metulburr. Edited 2 times in total.)

Good Morning,

I've written a program for a project in my intro to python class called: 6 Function Calculator. The functions are setup correctly. The part that isn't setup correctly is the 'while expression' or 'if expression' in line 36. I've used both if and while statements with the rest stayin the same. I commented out the while portion to show what else I was doing. The only thing that has not been changed on line 36 is the expression itself: integer1 <= 0 and integer1 <= 13 or integer2 <= 0 and integer2 <= 13:

I've taken notice that if I try to input 0 on any of the two integers that it will produce invalid input, but if I try to put a number above 13 it doesn't, it keeps running. Even when typing in a 0 as input it still keeps going. NEED HELP!

I've written a program for a project in my intro to python class called: 6 Function Calculator. The functions are setup correctly. The part that isn't setup correctly is the 'while expression' or 'if expression' in line 36. I've used both if and while statements with the rest stayin the same. I commented out the while portion to show what else I was doing. The only thing that has not been changed on line 36 is the expression itself: integer1 <= 0 and integer1 <= 13 or integer2 <= 0 and integer2 <= 13:

I've taken notice that if I try to input 0 on any of the two integers that it will produce invalid input, but if I try to put a number above 13 it doesn't, it keeps running. Even when typing in a 0 as input it still keeps going. NEED HELP!

####################################################################################################################### # Operation Functions def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): return x / y def exponent(x, y): return x ** y def remainder(x, y): return x % y ####################################################################################################################### # User Input / Input Variables integer1 = int(input("Enter an int between 1 $ 12: ")) integer2 = int(input("Enter an int between 1 $ 12: ")) # while integer1 <= 0 and integer1 <= 13 or integer2 <= 0 and integer2 <= 13: # print("Invalid Choice") # break if integer1 <= 0 and integer1 <= 13 or integer2 <= 0 and integer2 <= 13: print("Invalid Choice") else: print("Select operation.") print("1. (-A-) Addition Operation") print("2. (-S-) Subtraction Operation") print("3. (-M-) Multiplication Operation") print("4. (-D-) Divisional Operation") print("5. (-E-) Exponential Operation") print("6. (-R-) Remainder Operation") choice = input("Enter choice(A/S/M/D/E/R):") if choice == 'A' or choice == 'a': print(integer1, "+", integer2, "=", add(integer1, integer2)) elif choice == 'S' or choice == 's': print(integer1, "-", integer2, "=", subtract(integer1, integer2)) elif choice == 'M' or choice == 'm': print(integer1, "*", integer2, "=", multiply(integer1, integer2)) elif choice == 'D' or choice == 'd': print(integer1, "/", integer2, "=", divide(integer1, integer2)) elif choice == 'E' or choice == 'e': print(integer1, "^", integer2, "=", exponent(integer1, integer2)) elif choice == 'R' or choice == 'r': print(integer1, "%", integer2, "=", remainder(integer1, integer2)) else: print("Invalid Choice")