Marks Stu

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

FDS ASSIGNMENT

Write a python program to store marks scored in subject


“Fundamentals of Data Structure” by N students in the class.
Write functions to compute the following:
a) The average score of the class.
b) Highest score and lowest score of class.
c) Count of students who were absent for the test.
d) Display marks with highest frequency.
stu=int(input("Enter the total number of students:"))
present_stu=[]
absent_stu=[]
sum_marks=0
for i in range(stu):
marks=int(input("Enter the marks of student: "))
if marks==-1:
absent_stu.append(marks)
else:
sum_marks=sum_marks+marks
avg=sum_marks/stu
present_stu.append(marks)

def max_marks(present_stu):
max=present_stu[0]
for i in present_stu:
if i>max:
max=i
print("The maximum marks are: ",max)
return max
max_marks(present_stu)

def min_marks(present_stu):
min=present_stu[0]
for i in present_stu:
if i<min:
min=i
print("The minimum marks are: ",min )
return min
min_marks(present_stu)

def highest_frequency():
current_max=0
max_value=None
for i in present_stu:
if present_stu.count(i)>current_max:
current_max=present_stu.count(i)
max_value=i
print("The most frequent element is: ", max_value)
print("Number of occurences are: ", current_max)
highest_frequency()

print("The average marks are: ",avg)


print("Present students are: ",len(present_stu))
print("Absent students are: ",len(absent_stu))

Output:
Enter the total number of students:5
Enter the marks of student: 20
Enter the marks of student: 30
Enter the marks of student: -1
Enter the marks of student: 20
Enter the marks of student: 50
The maximum marks are: 50
The minimum marks are: 20
The most frequent element is: 20
Number of occurences are: 2
The average marks are: 24.0
Present students are: 4
Absent students are: 1

Process finished with exit code 0

You might also like