Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This statement introduces the Bot by name
- print("Hi, I am Marvin, your personal Bot.")
- #
- # Seeks input and allocates to variable "command"
- command=("Function")
- while command!="+" and command!="-" and command!="*" and command!="/":
- command=input("Select Function: +, -, *,/ ")
- #Requests numbers
- print("enter your numbers")
- input1 = input("Number 1> ")
- input2 = input("Number 2> ")
- #
- #Tests if Bot is to Add
- if command=="+":
- #converts to integer variables
- number1 = int(input1)
- number2 = int(input2)
- #completes calculation, converts result to string and prints
- result = number1 + number2
- output=str(result)
- print(input1 + " + " + input2 + " = " + output)
- #
- #Tests if Bot is to subtract
- elif command=="-":
- #converts to integer variables
- number1 = int(input1)
- number2 = int(input2)
- #completes calculation, converts result to string and prints
- result = number1 - number2
- output=str(result)
- print(input1 + " - " + input2 + " = " + output)
- #
- #Tests if Bot is to multiply
- elif command=="*":
- #converts to integer variables
- number1 = int(input1)
- number2 = int(input2)
- #completes calculation, converts result to string and prints
- result = number1 * number2
- output=str(result)
- print(input1 + " x " + input2 + " = " + output)
- #
- #Tests if Bot is to divide
- elif command=="/":
- #converts to integer variables
- number1 = int(input1)
- number2 = int(input2)
- #completes calculation, converts result to string and prints
- result = number1 / number2
- output=str(result)
- print(input1 + " / " + input2 + " = " + output)
- else:
- print("Do not understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement