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)
- elif command == "average":
- how_many = input("How many numbers> ")
- how_many = int(how_many)
- total = 0
- for number_count in range(how_many):
- number = input("Enter number " + str(number_count) + "> ")
- total = total + int(number)
- result = total / how_many
- print("The average = " + str(result))
- elif command == "meal":
- people = int(input("how many people ate a meal> "))
- total = 0
- for meal in range(people):
- cost = float(input("How much was meal " + str(meal+1) + "? "))
- total = total + cost
- print("Each person will need to pay " + str(round(total/people,2)) + " pounds\dollars each.")
- else:
- print("sorry I dont understand")
Advertisement
Add Comment
Please, Sign In to add comment