Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def do_calculation():
- print("lets " + command + " some numbers")
- input1 = input("Number 1>")
- input2 = input("Number 2>")
- number1 = int(input1)
- number2 = int(input2)
- if command == "add":
- result = number1 + number2
- elif command == "subtract":
- result = number1 - number2
- elif command == "multiply":
- result = number1 * number2
- if command == "add":
- print(str(input1) + " + " + str(input2) + " = " + str(result))
- elif command == "subtract":
- print(str(input1) + " - " + str(input2) + " = " + str(result))
- elif command == "multiply":
- print(str(input1) + " * " + str(input2) + " = " + str(result))
- ### Welcome ###
- print ("Hi, I am Albert, your personal bot.")
- users_name = input("What is your name?")
- print ("Welcome, " + users_name)
- ### Seleect Math Operation ###
- finished = False
- while finished == False:
- print ("I can do any of the following tasks for you: add two numbers, subtract numbers, or multiply numbers.")
- command = input("Type 'add', 'subtract', 'multiply' or 'end' to finish.")
- ### Perform Calculation ###
- if command == "add":
- do_calculation()
- elif command == "subtract":
- do_calculation()
- elif command == "multiply":
- do_calculation()
- ### End Program ###
- elif command == "end":
- finished = True
- print ("Thanks for using my smarts to help. Bye for now")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement