Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- print("Hi, I am Khamisi, your personal bot.")
- addition=["sum","add","plus","total","+"]
- #subtraction=["minus","subrtract","-","less","deduct"]
- multiplication=["multiply","times","*","product"]
- mean=["average","arithmetic mean","avg"]
- division=["div","divide","/"]
- command=input("choose operation: ")
- if command in mean:
- n = int(input("How many data do you have?: "))
- total = 0
- for count in range(n):
- data = int(input("Enter data number "+str(count)+":"))
- total+=data
- result=total/n
- print("the average of ",n,"numbers is: "+str(result))
- elif command in addition:
- n = int(input("How many data do you have?: "))
- total = 0
- for count in range(n):
- data = int(input("Enter data number "+str(count)+":"))
- total+=data
- result=total
- print("the addition of ",n,"numbers is: "+str(result))
- elif command in multiplication:
- n = int(input("How many data do you have?: "))
- product=1
- for count in range(n):
- data = int(input("Enter data number "+str(count)+":"))
- product*=data
- result=product
- print("the product of ",n,"numbers is: "+str(result))
- else:
- n = int(input("How many data do you have?: "))
- sumsquares=0
- sum=0
- for count in range(n):
- data = int(input("Enter data number "+str(count)+":"))
- sumsquares+=data*data
- sum+=data
- avg=sum/n
- result=sumsquares/n-avg
- result=math.sqrt(result)
- print("the standard deviation of ",n,"numbers is: "+str(result))
Add Comment
Please, Sign In to add comment