Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Hi, I am Mimi, your personal mathematics bot.")
- command = input("How can I help you today? Would you like to add, subtract, multiply or divide? Or maybe I could help you find the average of several numbers? I could even help you make up your shopping list! Please choose one. >")
- if command == "add":
- print("OK, let's add some numbers.")
- input1 = input("Number 1> ")
- input2 = input("Number 2> ")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 + number2
- output = str(result)
- print(input1 + " + " + input2 + " = " + output)
- print("Thanks for adding numbers with me. That was fun!")
- elif command == "subtract":
- print("OK, let's subtract some numbers.")
- input1 = input("Number 1> ")
- input2 = input("Number 2> ")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 - number2
- output = str(result)
- print(input1 + " - " + input2 + " = " + output)
- print("That was a good workout with numbers!")
- elif command == "multiply":
- print("OK, let's multiply some numbers.")
- input1 = input("Number 1> ")
- input2 = input("Number 2> ")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 * number2
- output = str(result)
- print(input1 + " * " + input2 + " = " + output)
- print("That was a good workout with numbers!")
- elif command == "divide":
- print("OK, let's divide some numbers.")
- input1 = input("Number 1> ")
- input2 = input("Number 2> ")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 / number2
- output = str(result)
- print(input1 + " / " + input2 + " = " + output)
- print("That was a good workout with numbers!")
- 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 + 1) + "> ")
- total = total + int(number)
- result = total / how_many
- print("The average comes out to " + str(result))
- print("That was fun!")
- elif command == "shopping":
- print("OK, then. Time to go shopping!")
- shopping = []
- cost = 0
- how_many = input("How many items will you be needing today? ")
- how_many = int(how_many)
- for item_number in range(how_many):
- item = input("What is item number " + str(item_number + 1)+ "? ")
- shopping.append(item)
- item_price = float(input("How much is that today? Just enter the price without the dollar sign please. >"))
- cost = cost + item_price
- print(shopping)
- print("Total cost of your shopping today is $" + str(cost))
- else:
- print("Sorry, I don't understand.")
- print("Bye.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement