Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Hi, I am Jim, your personal bot.")
- # ask the user their name
- name = input("What is your name? ")
- print("Hello " + name)
- validip = 0
- # what function do you want to do?
- command = input("type: add, subtract, multiply, or divide ")
- # get the 2 inputs
- if command == "add" or command == "subtract" or command == "multiply" or command == "divide":
- validip = 1
- # print(" valid request")
- else:
- validip = 0
- # print(" invalid request")
- if validip == 1:
- # get inputs
- input1 = input("Number 1 > ")
- input2 = input("Number 2 > ")
- number1 = int(input1)
- number2 = int(input2)
- # do - add, subtract, multiply, or divide
- if command == "add" or command == "plus":
- # print("add numbers")
- result = number1 + number2
- elif command == "subtract":
- # print("subtract numbers")
- result = number1 - number2
- elif command == "multiply":
- # print("multiply numbers")
- result = number1 * number2
- elif command == "divide":
- # print("divide numbers")
- result = number1 / number2
- if validip == 1:
- # print result
- output = str(result)
- print(input1 + " " + command + " " + input2 + " = " + output)
- # not +, -, *, /
- else:
- print("Invalid function selection")
- print("bye")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement