80 lines
1.8 KiB
Python
80 lines
1.8 KiB
Python
|
NoOfStudents = int(input("Enter number of students: "))
|
||
|
list1 = []
|
||
|
list2 = []
|
||
|
for i in range(0,NoOfStudents):
|
||
|
n = float(input("Enter student percentage: "))
|
||
|
list2.append(n)
|
||
|
for j in list2:
|
||
|
if(j != -1):
|
||
|
list1.append(j)
|
||
|
|
||
|
def avg():
|
||
|
sum1 = 0
|
||
|
for i in list1:
|
||
|
sum1 = sum1 + i
|
||
|
avg = sum1/NoOfStudents
|
||
|
print("Sum is: ",sum1)
|
||
|
print("Average is: ",avg)
|
||
|
|
||
|
def largest():
|
||
|
largest = None
|
||
|
for i in list1:
|
||
|
if(largest==None or largest<i):
|
||
|
largest = i
|
||
|
print("The highest marks is: ",largest)
|
||
|
|
||
|
def smallest():
|
||
|
smallest = None
|
||
|
for i in list1:
|
||
|
if(smallest==None or smallest>i):
|
||
|
smallest = i
|
||
|
print("The lowest marks is: ",smallest)
|
||
|
|
||
|
def absent():
|
||
|
abs = 0
|
||
|
for j in list2:
|
||
|
if(j == -1):
|
||
|
abs = abs + 1
|
||
|
print("Number of absent students are: ",abs)
|
||
|
|
||
|
def frequency():
|
||
|
temp = 0
|
||
|
for i in list1:
|
||
|
max1 = 0
|
||
|
for j in range(0,len(list1)):
|
||
|
if(i == list1[j]):
|
||
|
max1 = max1 + 1
|
||
|
else:
|
||
|
continue
|
||
|
if(max1>temp):
|
||
|
temp = max1
|
||
|
k = i
|
||
|
else:
|
||
|
continue
|
||
|
print("Marks with highest frequency is: ",k)
|
||
|
print("Frequency of the number is: ",temp)
|
||
|
|
||
|
flag = 1
|
||
|
while flag == 1:
|
||
|
print("\nThe options are: ")
|
||
|
print("1. Total and average marks are: ")
|
||
|
print("2. Highest marks among the students: ")
|
||
|
print("3. Lowest marks among the students: ")
|
||
|
print("4. Number of absent students: ")
|
||
|
print("5. Marks with highest frequency is: ")
|
||
|
print("6. Exit")
|
||
|
ch = int(input("Enter choice: "))
|
||
|
if(ch == 1):
|
||
|
avg()
|
||
|
elif(ch == 2):
|
||
|
largest()
|
||
|
elif(ch == 3):
|
||
|
smallest()
|
||
|
elif(ch == 4):
|
||
|
absent()
|
||
|
elif(ch == 5):
|
||
|
frequency()
|
||
|
elif(ch == 6):
|
||
|
flag = 0
|
||
|
elif(ch>6 or ch<1):
|
||
|
print("Enter valid choice")
|