Advertisement
Talithacelin

Simple calculator

Oct 16th, 2022 (edited)
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. #calculator
  2.  
  3. symbol = ['+' , '-' , '*', '/']
  4. print("Simple Calculator")
  5. print(symbol)
  6. print(20*'-')
  7.  
  8. while True:
  9.     n1 = int(input("Enter number: "))
  10.     symbol = input(
  11.         "Enter symbol: ")
  12.     n2 = int(input("Enter number: "))
  13.  
  14.     if symbol == '+':
  15.         t = n1 + n2
  16.         print (f"{n1} + {n2} = {t}")
  17.         print()
  18.  
  19.     elif symbol == '-':
  20.         t = n1 - n2
  21.         print (f"{n1} - {n2} = {t}")
  22.         print()
  23.  
  24.     elif symbol == '*':
  25.         t = n1 * n2
  26.         print (f"{n1} * {n2} = {t}")
  27.         print()
  28.  
  29.     elif symbol == '/':
  30.         t = n1 / n2
  31.         print (f"{n1} / {n2} = {t}")
  32.         print()
  33.  
  34.        
  35.  
  36.  
  37.  
  38.  
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement