Advertisement
KaySawbridge

Calculator

Sep 17th, 2020 (edited)
418
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. while True:
  2.     operator=input("Would you like to add, subtract, divide or multiply or exit? Please choose one. ")
  3.  
  4.     if operator=="add":
  5.         num1=int(input("What is the first number you would like to add? "))
  6.         num2=int(input("What is the second number you would like to add? "))
  7.         total=num1+num2
  8.     elif operator=="subtract":
  9.         num1=int(input("What number would you like to subtract from? "))
  10.         num2=int(input("Which number would you like to subtract? "))
  11.         total=num1-num2
  12.     elif operator=="divide":
  13.         num1=int(input("What number would you like to divide? "))
  14.         num2=int(input("Please input the number you would like to divide by "))
  15.         total=num1/num2
  16.     elif operator=="multiply":
  17.         num1=int(input("Please input the first number you would like to multiply "))
  18.         num2=int(input("Please input the second number you would like to multiply "))
  19.         total=num1*num2
  20.     elif operator=="exit":
  21.         break
  22.     else:
  23.         print ("The option you have chosen is not valid.")
  24.         continue
  25.     print ("The total is ",total)
Advertisement
RAW Paste Data Copied
Advertisement