SPPU SE FDS Group A-2 Code and output (2019 pattern)

 Problem Statement- "Write a Python Program to store marks scored in  subject "Fundamental of Data Structure " by N students in the class. Write functions to compute following:

        a) The average score of class

        b) Highest score and lowest score of class

        c) Count of students who were absent for the test

        d) Display mark with highest frequency

Solution -

CODE -


FDS=[]

N=int(input("Enter total number of student :"))
for i in range (N):
marks=int(input("Enter student marks or enter 0 for absent student :" +str(i+1)))
FDS.append(marks)
print(FDS)
def avg(lst):
sum=0
count=0
for i in lst:
if(i!=0):
sum=sum+i
count=count+i
avg=sum/N
return (str(avg))
def minimum(l):
min=l[0]
for i in range(len(l)):
if(l[i]!=0):
min=l[i]
break
for j in range(i+1,len(l)):
if l[j]!=0 and l[j]<min:
min=l[j]
return(min)
def maxmarks(lst):
max=lst[0]
for i in lst:
if i>max:
max=1
return (max)
def absent(lst):
abst=0
for i in lst:
if (i==o):
abst+=1
return(str(abst))

def maxfrequency(l):
i=0
max=0
print("marks frequecy cout:")
for ele in l:
if l.index(ele)==i:
print(ele,"--->",l.count(ele))
if l.count(ele)>max:
Max=l.count(ele)
mark=ele
i+=1
return(str(mark)+str(max))

flag=1
while flag==1:
print("MENU")
print("1.avg score of class is :")
print("2.minimum marks of the class is :")
print("3.maximum marks of the class is :")
print("4.no of absent student in class is :")
print("5.maximum frequency of class is :")
choice=int(input("Enter your choice :"))

if choice==1:
print("The average of class is :",(avg(FDS)))
elif choice==2:
print("The minimum score of class is :",(minimum(FDS)))
elif choice==3:
print("The maximum score of class is :",(maxmarks(FDS)))
elif choice==4:
print("NO of absent student in class is :",(absent(FDS)))
elif choice==5:
print("The frequency of class is :",(maxfrequency(FDS)))
else:
print("wrong choice")
flag=0


OUTPUT -



Thank you from Learning Bandhu

Please Subscribe to my YOUtube channel -

https://www.youtube.com/c/LearningBandhu


Comments

  1. subscriebe me on youtube - https://www.youtube.com/c/LearningBandhu

    ReplyDelete

Post a Comment