Advertisement
elena_gancedo

Def_option1

Jul 11th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 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.     elif command == "subtract":
  10.         result = number1 - number2
  11.     output = str(result)
  12.     if command == "add":
  13.         print(input1 + " + " + input2 + " = " + output)
  14.     elif command == "subtract":
  15.         print(input1 + " - " + input2 + " = " + output)
  16. finished = False
  17. while finished == False:
  18.     print("Hi, I am Eley, your personal bot.")
  19.     command = input("If you want to calculate some numbers write 'add' or 'subtract': ")
  20.     if command == "add":
  21.         do_calculation()
  22.     elif command == "subtract":
  23.         do_calculation()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement