Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to make calculator in python

while True:
 print("1 Adition")
 print("2 Subtraction")
 print("3 multiplication")
 print("4 Division")

 choice = input("Enter your choice : ")

 num1 = float(input("Enter number 1 : "))
 num2 = float(input("Enter number 2 : "))

 if choice == "1":
     print(num1, "+", num2, "=", (num1+num2))
 elif choice == "2":
     print(num1, "-", num2, "=", (num1-num2))
 if choice == "3":
     print(num1, "*", num2, "=", (num1*num2))
 elif choice == "4":
     if num2 == 0.0:
       ("print"eror 303")
     else:
         print(num1, "/", num2, "=", (num1/num2))

 else:
     print("invalic choice")

   
 
PREVIOUS NEXT
Tagged: #calculator #python
ADD COMMENT
Topic
Name
6+4 =