scipiguy

Python 101: Bot with additional command 'meal'

Apr 22nd, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.16 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. elif command == "average":
  43.     how_many = input("How many numbers> ")
  44.     how_many = int(how_many)
  45.     total = 0
  46.    
  47.     for number_count in range(how_many):
  48.         number = input("Enter number " + str(number_count) + "> ")
  49.         total = total + int(number)
  50.    
  51.     result = total / how_many
  52.     print("The average = " + str(result))
  53. elif command == "meal":
  54.     people = int(input("how many people ate a meal> "))
  55.     total = 0
  56.    
  57.     for meal in range(people):
  58.         cost = float(input("How much was meal " + str(meal+1) + "? "))
  59.         total = total + cost
  60.        
  61.     print("Each person will need to pay " + str(round(total/people,2)) + " pounds\dollars each.")
  62. else:
  63.     print("sorry I dont understand")
Advertisement
Add Comment
Please, Sign In to add comment