loop = 1
choice = 0 #holds the user choice for menu
while (loop == 1):
print ("Welcome to calci.py")
print ("your options are:")
print (" ")
print ("1. Addition")
print ("2. Subtraction")
print ("3. Multiplication")
print ("4. Division")
print ("5. Quit calculator.py")
print (" ")
choice = input("Choose your option: ")
if (choice == 1):
add1 = input("Add this: ")
add2 = input("to this: ")
print (add1, "+", add2, "=", add1 + add2)
elif (choice == 2):
sub2 = input("Subtract this: ")
sub1 = input("from this: ")
print (sub1, "-", sub2, "=", sub1 - sub2)
elif (choice == 3):
mul1 = input("Multiply this: ")
mul2 = input("with this: ")
print (mul1, "*", mul2, "=", mul1 * mul2)
elif (choice == 4):
div1 = input("Divide this: ")
div2 = input("by this: ")
print (div1, "/", div2, "=", div1/div2)
elif (choice == 5):
loop = 0
print ("Thankyou for using calci.py!")
Я новичок в мире python, я написал и скомпилировал код калькулятора, но его не работает, нужна помощь!Базовая программа калькулятора не работает в Python idle
«Не работает» не является конкретной проблемой. Любые ошибки? Является ли логическая ошибка? Почему ты так думаешь? Какие ценности вы принимаете? Что ты вернешь? Чего ты ожидал? Как вы пытались это исправить? – Ben
Это работает для меня. Укажите точную ошибку/проблему. –
Это Python 3 или 2? Если это Python 2, я вижу, что вы используете целочисленное деление ... – irrelephant