Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Introduce yourself to your visitor
- print("Hi, I am Rotellity, the Funky Maths bot.")
- print("I came, I saw, I added, subtracted, multiplied and calculated percentages!")
- # Ask the visitor a question.
- # Use inputs to collect their responses
- # Use number variables to convert the input replies into integers
- # Use output to convert the result into a string
- command = input("How can I help?")
- if command == "add" or command == "plus":
- print("let's add some numbers")
- input1 = input("Pick a number, any number!>")
- input2 = input("Now pick a second number>")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 + number2
- output = str(result)
- print("Watch me add both numbers! " + input1 + " + " + input2 + " = " + output)
- elif command == "subtract" or command == "minus":
- print("let's subtract some numbers")
- input1 = input("Start by picking one number, any number!")
- input2 = input("Now, pick a second number, any one will do!")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 - number2
- output = str(result)
- print("Watch me substract both numbers! " +input1 + " - " + input2 + " = " + output)
- elif command == "multiply" or command == "times":
- print("let's multiply two numbers!")
- input1 = input("Pick your first number")
- input2 = input("Pick your second number")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 * number2
- output = str(result)
- print("Let's multiply! " +input1 + " x " + input2 + " = " + 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))
- else:
- print("Sorry, I am but a simple maths bot. I do not understand your request.")
- print("Let's calculate your amount you spend on groceries")
- input1 = input("How much did you spend this week on groceries?")
- input2 = input("How much did you earn this week?")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 / number2
- output = str(result)
- print("Groceries made up " +output + " percent of your budget for the week.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement