lubattillah

stats

May 16th, 2019
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. import math
  2. print("Hi, I am Khamisi, your personal bot.")
  3. addition=["sum","add","plus","total","+"]
  4. #subtraction=["minus","subrtract","-","less","deduct"]
  5. multiplication=["multiply","times","*","product"]
  6. mean=["average","arithmetic mean","avg"]
  7. division=["div","divide","/"]
  8. command=input("choose operation: ")
  9. if command in mean:
  10. n = int(input("How many data do you have?: "))
  11. total = 0
  12. for count in range(n):
  13. data = int(input("Enter data number "+str(count)+":"))
  14. total+=data
  15. result=total/n
  16. print("the average of ",n,"numbers is: "+str(result))
  17. elif command in addition:
  18. n = int(input("How many data do you have?: "))
  19. total = 0
  20. for count in range(n):
  21. data = int(input("Enter data number "+str(count)+":"))
  22. total+=data
  23. result=total
  24. print("the addition of ",n,"numbers is: "+str(result))
  25. elif command in multiplication:
  26. n = int(input("How many data do you have?: "))
  27. product=1
  28. for count in range(n):
  29. data = int(input("Enter data number "+str(count)+":"))
  30. product*=data
  31. result=product
  32. print("the product of ",n,"numbers is: "+str(result))
  33. else:
  34. n = int(input("How many data do you have?: "))
  35. sumsquares=0
  36. sum=0
  37. for count in range(n):
  38. data = int(input("Enter data number "+str(count)+":"))
  39. sumsquares+=data*data
  40. sum+=data
  41. avg=sum/n
  42. result=sumsquares/n-avg
  43. result=math.sqrt(result)
  44. print("the standard deviation of ",n,"numbers is: "+str(result))
Add Comment
Please, Sign In to add comment