0% found this document useful (0 votes)
3 views

Assignment No 2

Assignment 2

Uploaded by

k9172056115
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Assignment No 2

Assignment 2

Uploaded by

k9172056115
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

ASSIGNMENT NO-2

Name:- Kishor Tanaji Pawar

Roll No:-COC063

Batch:-C3

Code:
def accept_marks(A):

n=int(input("Enter the total no. of student :")) for i in range(n):

while True: x=input("Enter the marks scored in FDS for student

%d :"%(i+1))

if(x=="AB"): x==-1

#indicates Absent students

break

x=int(x) if(x>=0

and x<=30):

break

else:

print("Plz enter valid marks out of 30")

A.append(x) print("Marks accepted and stored

successfully"); def display_marks(A):

print("\nMarks Scored in FDS")

for i in range(len(A)):

if(A[i]=="AB"):

print("\tStudent %d : AB"%(i+1))

else:

print("\tStudent %d : %d"%(i+1,A[i]))
def search_set(A,x):

n=len(A) for i

in range(n):

if(A[i]==x):

return(1)

return(0)

def find_average_score_of_class(A):

sum=0 for i in

range(len(A)):

if(A[i]!=-1):

sum=sum+A[i]

avg=sum/len(A)

display_marks(A) print("\nAverage score of

class is %.2f\n\n"%avg)

def find_highest_and_lowest_score_of_class(A):

max=-1 min=31

for i in range(1,len(A)):

if(max<A[i]):

max=A[i] max_ind=i

if(min>A[i] and A[i]!=-1):


min=A[i] min_ind=i display_marks(A) print("Highest Mark Score of

class is %d scored by student %d"%(max,max_ind+1)) print("Lowest Mark Score of

class is %d scored by student %d"%(min,min_ind+1))

def find_count_of_absent_students(A):

count=0 for i in range(len(A)): if(A[i]==-

1): count+=1 display_marks(A)

print("\tAbsent Student Count = %d"%count)

def display_mark_with_highest_frequency(A):

freq=0 for i in

range(len(A)):

count=0 if(A[i]!=-

1): for j in

range(len(A)):

if(A[i]==A[j]):

count+=1

if(freq<count):

Marks=A[i] freq=count

display_marks(A) print("\

nMarks with highest

frequency is %d(%d)"%

(Marks,freq))
def main():

FDS_Marks=[] while

True:

print("\t\t1 :Accept FDS Marks") print("\t\t2 :Average

score of class") print("\t\t3 :Highest score and lowest score of

class") print("\t\t4 :Count of students who were absent for

the test") print("\t\t5 :Display mark with highest frequency")

print("\t\t6 :Exit") ch=int(input("Enter your choice :"))

if(ch==6): print("End of Program") break

elif(ch==1):

accept_marks(FDS_Marks)

display_marks(FDS_Marks) elif(ch==2):

find_average_score_of_class(FDS_Marks)

elif(ch==3):

find_highest_and_lowest_score_of_class(FDS_Marks)

elif(ch==4):

find_count_of_absent_students(FDS_Marks)

elif(ch==5):

display_mark_with_highest_frequency(FDS_Marks)

else:

print("Wrong choice entered !! Try again") main()

Output:-
1 :Accept FDS Marks

2 :Average score of class


3 :Highest score and lowest score of class

4 :Count of students who were absent for the test

5 :Display mark with highest frequency

6 :Exit

Enter your choice :1

Enter the total no. of student :5

Enter the marks scored in FDS for student 1 :20

Enter the marks scored in FDS for student 2 :10

Enter the marks scored in FDS for student 3 :18

Enter the marks scored in FDS for student 4 :25

Enter the marks scored in FDS for student 5 :30

Marks accepted and stored successfully

Marks Scored in FDS

Student 1 : 20

Student 2 : 10

Student 3 : 18

Student 4 : 25

Student 5 : 30

1 :Accept FDS Marks

2 :Average score of class

3 :Highest score and lowest score of class

4 :Count of students who were absent for the test

5 :Display mark with highest frequency

6 :Exit
Enter your choice :2

Marks Scored in FDS

Student 1 : 20

Student 2 : 10

Student 3 : 18

Student 4 : 25

Student 5 : 30

Average score of class is 20.60

1 :Accept FDS Marks

2 :Average score of class

3 :Highest score and lowest score of class

4 :Count of students who were absent for the test

5 :Display mark with highest frequency

6 :Exit

Enter your choice :3

Marks Scored in FDS

Student 1 : 20

Student 2 : 10

Student 3 : 18

Student 4 : 25
Student 5 : 30

Highest Mark Score of class is 30 scored by student 5

Lowest Mark Score of class is 10 scored by student 2

1 :Accept FDS Marks

2 :Average score of class

3 :Highest score and lowest score of class

4 :Count of students who were absent for the test

5 :Display mark with highest frequency

6 :Exit

Enter your choice :4

Marks Scored in FDS

Student 1 : 20

Student 2 : 10

Student 3 : 18

Student 4 : 25

Student 5 : 30

Absent Student Count = 0

1 :Accept FDS Marks

2 :Average score of class

3 :Highest score and lowest score of class

4 :Count of students who were absent for the test

5 :Display mark with highest frequency

6 :Exit

Enter your choice :5


Marks Scored in FDS

Student 1 : 20

Student 2 : 10

Student 3 : 18

Student 4 : 25

Student 5 : 30

Marks with highest frequency is 20(1)

1 :Accept FDS Marks

2 :Average score of class

3 :Highest score and lowest score of class

4 :Count of students who were absent for the test

5 :Display mark with highest frequency

6 :Exit

Enter your choice :6

End of Program

You might also like