Advertisement
rickzman

Untitled

Dec 4th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #
  2. print("Hi, my am marvin, your personal bot.")
  3. users_name = input("What is your name? ")
  4. print("Welcome "+ users_name)
  5.  
  6.  
  7. #print("Let's add or subtract some numbers")
  8. input1 = float(input("Enter number 1> "))
  9. input2 = float(input("Enter number 2> "))
  10.  
  11. # add or subtract??
  12. anser = input("Do you want to add, subtract, multiply, divide or average ?")
  13.  
  14. if anser == "add":
  15. result = input1 + input2
  16. print(input1, "+", input2, "=", result)
  17. elif anser == "subtract":
  18. result = input1 - input2
  19. print(input1, "-", input2, "=", result)
  20. elif anser == "multiply":
  21. result = input1 * input2
  22. print(input1, "*", input2, "=", result)
  23. elif anser == "divide":
  24. result = input1 / input2
  25. print(input1, "/", input2, "=", result)
  26. elif anser == "average":
  27. how_many = int(input("How many more numbers?"))
  28. total = input1 + input2
  29. # enter the additional numbers
  30. for number_count in range(how_many):
  31. number = int(input("Enter number " + str(number_count + 3)+ "> "))
  32. total = total + number
  33. # average all the numbers
  34. result = total/(how_many+ 2)
  35. print("The average of the", str(how_many+ 2),"numbers is", str(result))
  36.  
  37. else:
  38. print("I don't understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement