Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. #This statement introduces the Bot by name
  2. print("Hi, I am Marvin, your personal Bot.")
  3. #
  4. # Seeks input and allocates to variable "command"
  5. command=("Function")
  6. while command!="+" and command!="-" and command!="*" and command!="/":
  7. command=input("Select Function: +, -, *,/ ")
  8.  
  9. #Requests numbers
  10. print("enter your numbers")
  11. input1 = input("Number 1> ")
  12. input2 = input("Number 2> ")
  13. #
  14. #Tests if Bot is to Add
  15. if command=="+":
  16. #converts to integer variables
  17. number1 = int(input1)
  18. number2 = int(input2)
  19. #completes calculation, converts result to string and prints
  20. result = number1 + number2
  21. output=str(result)
  22. print(input1 + " + " + input2 + " = " + output)
  23. #
  24. #Tests if Bot is to subtract
  25. elif command=="-":
  26. #converts to integer variables
  27. number1 = int(input1)
  28. number2 = int(input2)
  29. #completes calculation, converts result to string and prints
  30. result = number1 - number2
  31. output=str(result)
  32. print(input1 + " - " + input2 + " = " + output)
  33. #
  34. #Tests if Bot is to multiply
  35. elif command=="*":
  36. #converts to integer variables
  37. number1 = int(input1)
  38. number2 = int(input2)
  39. #completes calculation, converts result to string and prints
  40. result = number1 * number2
  41. output=str(result)
  42. print(input1 + " x " + input2 + " = " + output)
  43. #
  44. #Tests if Bot is to divide
  45. elif command=="/":
  46. #converts to integer variables
  47. number1 = int(input1)
  48. number2 = int(input2)
  49. #completes calculation, converts result to string and prints
  50. result = number1 / number2
  51. output=str(result)
  52. print(input1 + " / " + input2 + " = " + output)
  53. else:
  54. print("Do not understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement