Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

make calculator in python

option = int(input("Enter Your Choice 1(Add)/2(Sub)/3(Divide)/4(Multiply): "))

# Check if the option is a valid operation
if option > 4:
    print("enter a valid Number")
    exit()
    
# Get the 2 numbers which will be calculating on
num1 = int(input("Enter Number 1: "))
num2 = int(input("Enter Number 2: "))

if option == 1:
    print("The Sum Is ", num1 + num2)
elif option == 2:
    print("The Difference Is ", num1 - num2)
elif option == 3:
    print("The Division Is ", num1 / num2)
elif option == 4:
    print("The Product Is ", num1 * num2)
elif option == 5:
    print("The Power Is ", num1 ** num2)
 
PREVIOUS NEXT
Tagged: #calculator #python
ADD COMMENT
Topic
Name
8+9 =