Professional Documents
Culture Documents
Add Add+ - (X) : Range (0, A)
Add Add+ - (X) : Range (0, A)
Source code :
#To calculate mnean
def mean(l):
add=0
for x in range(0,a):
add=add+|[x]
mean=add/a
print("'mean of the given list is ",mean)
#to calculate median
def median(l):
I.sort()
print("sortedorder of list :")
if(a%2==0):
nl=//2
n2=nl-1
md-(U[nl+l[n2])/2
print("median is".md)
else:
PYTHON PROGRAMMING
APPLICATIONS LAB
n=al/2
print("median is",I[n])
#calculate mode
det mode(l):
for x in I:
|l.append(l.count())
m=max(1)
print("mode is",I[l1.index(m))
#read size and elements into list
I1=0
i=0
m=int(input("Enter the size of the list:")
while(i<m):
L.append(int(input("enter the element:")
i=i+l
print("the list contains:")
a=len(l)
mean(l)
median(|)
mode(l)
Output:
Enter the size of the list:4
mode is 1