Thursday 15 February 2024

Class 11 CS Practical - 49

 

49 - WAP in the Python to create a list and find the mean of all numeric values stored in the list.


L=eval(input("Enter a list: "))

n=len(L)

N=[]

for i in L:

    if isinstance(i,int) or isinstance(i,float):

        N.append(i)

print("Mean of numeric values stored in the list:")

print(sum(N)/len(N))


Output:

Enter a list: [5,'A',9,6.5,'Python',3.5]

Mean of numeric values stored in the list:

6.0



No comments:

Post a Comment