Python Program To Store Marks
# Group A - 2
# 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
try:
list1 = []
userinput1 = int(input("Enter The Numbers Of Students Who Attended The Test - "))
for k in range(userinput1):
marks = int(input(f"Enter The Marks Of Student {k + 1} - "))
list1.append(marks)
def average(list1):
sum = 0
counter = 0
for marks in list1:
sum = sum + marks
counter = counter + 1
avg = sum / counter
print("\nTotal Score =", sum)
print("Average Score Of Class Is =", avg, "%", "\n")
average(list1)
def maximum(list1):
max = list1[0]
for val in range(len(list1)):
if list1[val] > max:
max = list1[val]
print("Maximum Score Of Class Is =", max, "\n")
maximum(list1)
def minimum(list1):
min = list1[0]
for val in range(len(list1)):
if list1[val] < min:
min = list1[val]
print("Minimum Score Of Class Is =", min, "\n")
minimum(list1)
def absent(list1):
total = int(input("Enter Total Number of Students In Class\n"))
print("Number Of Absent Students Is", total - len(list1), "\n")
absent(list1)
def highFrequency(list1):
maxcount = 0
max = 0
for element in list1:
if list1.index(element) == maxcount:
print(f"The Count Of {element} Marks Is {list1.count(element)}")
if list1.count(element) > max:
max = list1.count(element)
maxcount = maxcount + 1
dict = {}
for ele in list1:
if list1.count(ele) == max:
dict.update({f"Marks = {ele}": f"Frequency = {list1.count(ele)}"})
print(f"\nThe Dictionary Of Marks With Highest Frequency Is{dict}")
highFrequency(list1)
except Exception as e:
print("Wrong Input,Enter Integers Only!!")
#Output #
# Enter The Numbers Of Students Who Attended The Test - 10
# Enter The Marks Of Student 1 - 98
# Enter The Marks Of Student 2 - 98
# Enter The Marks Of Student 3 - 89
# Enter The Marks Of Student 4 - 89
# Enter The Marks Of Student 5 - 56
# Enter The Marks Of Student 6 - 48
# Enter The Marks Of Student 7 - 84
# Enter The Marks Of Student 8 - 85
# Enter The Marks Of Student 9 - 88
# Enter The Marks Of Student 10 - 94
# Total Score = 829
# Average Score Of Class Is = 82.9 %
# Maximum Score Of Class Is = 98
# Minimum Score Of Class Is = 48
# Enter Total Number of Students In Class
# 12
# Number Of Absent Students Is 2
# The Count Of 98 Marks Is 2
# The Count Of 89 Marks Is 2
# The Count Of 56 Marks Is 1
# The Count Of 48 Marks Is 1
# The Count Of 84 Marks Is 1
# The Count Of 85 Marks Is 1
# The Count Of 88 Marks Is 1
# The Count Of 94 Marks Is 1
# The Dictionary Of Marks With Highest Frequency Is { 'Marks = 98':'Frequency = 2', 'Marks = 89': 'Frequency = 2'}
thank you so much
ReplyDelete