Advertisement
DEP21

Untitled

May 18th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. print ("Hi, I am Martin your personal Bot.")
  2. command = input("What would you like to do - add, subtract, multiply, divide or the average? ")
  3.  
  4. if command == "plus" or command == "add":
  5. print("Let's add some numbers")
  6. input1 = input("Input number 1 ")
  7. input2 = input("Input number 2 ")
  8. number1 = int(input1)
  9. number2 = int(input2)
  10. result = number1 + number2
  11. output = str(result)
  12. print(input1 + "+" + input2 + "=" + output)
  13. elif command == "subtract":
  14. print("Let's subtract some numbers")
  15. input1 = input("Input number 1 ")
  16. input2 = input("Input number 2 ")
  17. number1 = int(input1)
  18. number2 = int(input2)
  19. result = number1 - number2
  20. output = str(result)
  21. print(input1 + "-" + input2 + "=" + output)
  22. elif command == "multiply":
  23. print("Let's multiply some numbers")
  24. input1 = input("Input number 1 ")
  25. input2 = input("Input number 2 ")
  26. number1 = int(input1)
  27. number2 = int(input2)
  28. result = number1 * number2
  29. output = str(result)
  30. print(input1 + "x" + input2 + "=" + output)
  31.  
  32. elif command == "divide":
  33. print("Let's divide some numbers")
  34. input1 = input("Input number 1 ")
  35. input2 = input("Input number 2 ")
  36. number1 = int(input1)
  37. number2 = int(input2)
  38. result = number1/number2
  39. output = str(result)
  40. print(input1 + "รท" + input2 + "=" + output)
  41.  
  42. elif command == "average" or command == "the average":
  43. how_many = input("How many numbers? ")
  44. how_many = int(how_many)
  45. total = 0
  46. for number_count in range(how_many):
  47. number = input("Enter number " + str(number_count) + " ")
  48. total = total + int(number)
  49. output = total/how_many
  50. print("The average = " + str(output))
  51.  
  52. else:
  53. print("sorry I don't understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement