Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Futurelearn: Python 101 from RPi Foundation - Bot with + - * / selection
- print("Hi, I am your personal 'bot' called Dave.")
- command = input("How can I help you? ")
- if command == "add" or command == "plus":
- print("Let's add some numbers")
- input_1 = input("Number 1> ")
- input_2 = input("Number 2> ")
- number_1 = int(input_1)
- number_2 = int(input_2)
- result = number_1 + number_2
- output = str(result)
- print(input_1 + " + " + input_2 + " = " + output)
- elif command == "subtract" or command == "take away":
- print("Let's subtract some numbers")
- input_1 = input("Number 1> ")
- input_2 = input("Number 2> ")
- number_1 = int(input_1)
- number_2 = int(input_2)
- result = number_1 - number_2
- output = str(result)
- print(input_1 + " - " + input_2 + " = " + output)
- elif command == "multiply" or command == "times":
- print("Let's multiply some numbers")
- input_1 = input("Number 1> ")
- input_2 = input("Number 2> ")
- number_1 = int(input_1)
- number_2 = int(input_2)
- result = number_1 * number_2
- output = str(result)
- print(input_1 + " * " + input_2 + " = " + output)
- elif command == "divide":
- print("Let's divide some numbers")
- input_1 = input("Number 1> ")
- input_2 = input("Number 2> ")
- number_1 = int(input_1)
- number_2 = int(input_2)
- result = number_1 / number_2
- output = str(result)
- print(input_1 + " / " + input_2 + " = " + output)
- else:
- print("sorry I dont understand")
Advertisement
Add Comment
Please, Sign In to add comment