• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled Michael_J_T  Aug 24th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. def do_calculation():
2.     print("lets " + command + " some numbers")
3.     input1 = input("Number 1>")
4.     input2 = input("Number 2>")
5.     number1 = int(input1)
6.     number2 = int(input2)
7.     if command == "add":
8.         result = number1 + number2
9.     elif command == "subtract":
10.         result = number1 - number2
11.     elif command == "multiply":
12.         result = number1 * number2
13.     if command == "add":
14.         print(str(input1) + " + " + str(input2) + " = " + str(result))
15.     elif command == "subtract":
16.         print(str(input1) + " - " + str(input2) + " = " + str(result))
17.     elif command == "multiply":
18.         print(str(input1) + " * " + str(input2) + " = " + str(result))
19.
20. ### Welcome ###
21. print ("Hi, I am Albert, your personal bot.")
22. users_name = input("What is your name?")
23. print ("Welcome, " + users_name)
24. ### Seleect Math Operation ###
25. finished = False
26. while finished == False:
27.   print ("I can do any of the following tasks for you: add two numbers, subtract numbers, or multiply numbers.")
28.   command = input("Type 'add', 'subtract', 'multiply' or 'end' to finish.")
29.   ### Perform Calculation ###
30.   if command == "add":
31.     do_calculation()
32.   elif command == "subtract":
33.     do_calculation()
34.   elif command == "multiply":
35.     do_calculation()
36.   ### End Program ###
37.   elif command == "end":
38.     finished = True
39.
40. print ("Thanks for using my smarts to help. Bye for now")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top