Advertisement
Pedroleon

add_substract_divide_multiply and AVERAGE

Jan 12th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. print("Hi, I am Marvin, your personal bot.")
  2. phrase = input("Whats your name ? >")
  3. print(" Morning " + phrase)
  4. print("Do you want to divide, multiply , add or substract. OR average ?")
  5. command = input("How can I help ? >")
  6. if command == "divide" or command == "plus":
  7. print("Let's divide 2 numbers.")
  8. input1 = input("Number 1> ") # input numbers are strings#
  9. input2 = input("Number 2> ")
  10. number1 = int(input1) # use int to convert string to integer#
  11. number2 = int(input2)
  12. result = number1 / number2 # by using add #
  13. output = str(result) # result of operation#
  14. print(input1 + " / " + input2 + " = " + output)
  15. elif command == "multiply":
  16. print(" Let's multiply 2 numbers.")
  17. input1 = input("Number 1> ")
  18. input2 = input("Number 2> ")
  19. number1 = int(input1)
  20. number2 = int(input2)
  21. result = number1 * number2
  22. output = str(result)
  23. print(input1 + " * " + input2+" = " + output)
  24. elif command == "add":
  25. print(" Let's add 2 numbers.")
  26. input1 = input("Number 1> ")
  27. input2 = input("Number 2> ")
  28. number1 = int(input1)
  29. number2 = int(input2)
  30. result = number1 + number2
  31. output = str(result)
  32. print(input1 + " + " + input2+" = " + output)
  33. elif command == "substract":
  34. print(" Let's substract 2 numbers.")
  35. input1 = input("Number 1> ")
  36. input2 = input("Number 2> ")
  37. number1 = int(input1)
  38. number2 = int(input2)
  39. result = number1 - number2
  40. output = str(result)
  41. print(input1 + " - " + input2+" = " + output)
  42.  
  43.  
  44. elif command == "average":
  45. print("NOW find average")
  46. how_many = input("How many numbers > ")
  47. how_many = int(how_many)
  48. total = 0
  49. for number_count in range(how_many):
  50. number = input("Enter number " + str(number_count) + "?")
  51. total = total + int(number)
  52. result = total /how_many
  53. print("the average = " + str(result))
  54. else:
  55. print("Sorry I don't understand")
  56. print("Well done" + phrase)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement