Advertisement
elena_gancedo

Def_option2

Jul 11th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. def do_calculation():
  2.     print("Let's " + command + " some numbers: ")
  3.     input1 = input("Number 1> ")
  4.     input2 = input("Number 2> ")
  5.     number1 = int(input1)
  6.     number2 = int(input2)
  7.     if command == "add":
  8.         result = number1 + number2
  9.         operator = " + "
  10.     elif command == "subtract":
  11.         result = number1 - number2
  12.         operator = " - "
  13.     output = str(result)
  14.     print(input1 + operator + input2 + " = " + output)
  15. finished = False
  16. while finished == False:
  17.     print("Hi, I am Eley, your personal bot.")
  18.     command = input("If you want to calculate some numbers write 'add' or 'subtract': ")    
  19.     if command == "add":
  20.         do_calculation()
  21.     elif command == "subtract":
  22.         do_calculation()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement