scipiguy

Python 101: Maths with selection

Apr 22nd, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.49 KB | None | 0 0
  1. # Futurelearn: Python 101 from RPi Foundation - Bot with + - * / selection
  2. print("Hi, I am your personal 'bot' called Dave.")
  3.  
  4. command = input("How can I help you? ")
  5.  
  6. if command == "add" or command == "plus":
  7.     print("Let's add some numbers")
  8.     input_1 = input("Number 1> ")
  9.     input_2 = input("Number 2> ")
  10.     number_1 = int(input_1)
  11.     number_2 = int(input_2)
  12.     result = number_1 + number_2
  13.     output = str(result)
  14.     print(input_1 + " + " + input_2 + " = " + output)
  15. elif command == "subtract" or command == "take away":
  16.     print("Let's subtract some numbers")
  17.     input_1 = input("Number 1> ")
  18.     input_2 = input("Number 2> ")
  19.     number_1 = int(input_1)
  20.     number_2 = int(input_2)
  21.     result = number_1 - number_2
  22.     output = str(result)
  23.     print(input_1 + " - " + input_2 + " = " + output)
  24. elif command == "multiply" or command == "times":
  25.     print("Let's multiply some numbers")
  26.     input_1 = input("Number 1> ")
  27.     input_2 = input("Number 2> ")
  28.     number_1 = int(input_1)
  29.     number_2 = int(input_2)
  30.     result = number_1 * number_2
  31.     output = str(result)
  32.     print(input_1 + " * " + input_2 + " = " + output)
  33. elif command == "divide":
  34.     print("Let's divide some numbers")
  35.     input_1 = input("Number 1> ")
  36.     input_2 = input("Number 2> ")
  37.     number_1 = int(input_1)
  38.     number_2 = int(input_2)
  39.     result = number_1 / number_2
  40.     output = str(result)
  41.     print(input_1 + " / " + input_2 + " = " + output)
  42. else:
  43.     print("sorry I dont understand")
Advertisement
Add Comment
Please, Sign In to add comment