Repository navigation
Expand file tree
/
Copy path1_student-mark-analysis.py
More file actions
160 lines (105 loc) · 5.2 KB
/
Copy path1_student-mark-analysis.py
File metadata and controls
160 lines (105 loc) · 5.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#Numpy_project1
#student-mark-analysis
import numpy as np
np.random.seed(42)#creates different marks for all
marks = np.random.randint(35,101,size=(30,5))
subject =["Math","Physics", "Chemistry", "English", "Computer Science"]
student_names = [
"Ayaan", "Zara", "Farhan", "Nusrat", "Rakib",
"Sadia", "Tanvir", "Meem", "Imran", "Puja",
"Shakil", "Lamia", "Rabby", "Anika", "Sojib",
"Sumaiya", "Mahmud", "Nadia", "Jahangir", "Maliha",
"Ashik", "Tanjim", "Fahmida", "Raihan", "Orpi",
"Nabil", "Tasnia", "Sabbir", "Sharmin", "Zubair"
]
totalmarks = np.sum(marks,axis =1)
averagemarks = np.mean(marks,axis=1)
averagesubject = np.mean(marks, axis =0)
highestmarkssub = np.argmax(averagesubject)
lowestsub = np.argmin(averagesubject)
while True:
print("=================================================================================")
print("1.The average mark of each student.")
print("2.Overall class topper.")
print("3.Student with the lowest overall average.")
print("4.The highest and lowest scored subject.")
print("5.The student who scored above 90 in all subjects. ")
print("6.Grade of each student in each subject.")
print("7.Grade according to averagemarks of each student")
print("8.The students who passed all five subjects.")
print("9.The student who failed in any subject.")
print("10.Exit")
print("================================================================================")
try:
choice = int(input("choose from above:"))
if choice == 1:
for i in range(len(marks)):
print(f"{student_names[i]} has a average marks of {averagemarks[i]}")
elif choice ==2:
topper_index= np.argmax(averagemarks)
print(f"The topper of the class is {student_names[topper_index]}")
elif choice == 3:
backbencher_index = np.argmin(averagemarks)
print(f"The lowest scores student of the class is {student_names[backbencher_index]}")
elif choice==4:
print(f"The highest scored subject is {subject[highestmarkssub] }")
print(f"The lowest scored subject is {subject[lowestsub] }")
elif choice ==5:
ninetyabove = np.all(marks>90, axis =1)
ninety_index = np.where(ninetyabove)[0]
if len(ninety_index) > 0:
for i in ninety_index:
print(student_names[i])
else:
print("There are none.")
elif choice ==6:
condition_marks = [marks >=90,
marks >=80,
marks>=70,
marks>=60,
marks>=50,
marks>=40
]
grades = ["A+","A","A-","B","C","D"]
fixing_grades =np.select(condition_marks,grades,default = "F")
for i in range(len(student_names)):
print("--------------------------------------------------------------------")
print(f"Student : {student_names[i]}")
for j in range(len(subject)):
print(f" {subject[j]} : {fixing_grades[i,j]}" )
elif choice ==7:
condition_average = [averagemarks >= 90,
averagemarks >= 80,
averagemarks >= 70,
averagemarks >= 60,
averagemarks >= 50,
averagemarks >= 40
]
grades = ["A+","A","A-","B","C","D"]
fixing_grades_final = np.select(condition_average,grades, default ="F")
for i in range(len(averagemarks)):
print("-------------------------------------------------------------")
print(f"Name :{student_names[i]} \n Grade: {fixing_grades_final[i]}")
elif choice ==8:
passedall = np.all(marks>= 40,axis =1)
passed_index = np.where(passedall)[0]
if len(passed_index)>0:
for i in passed_index:
print(f"The student who passed in all 5 subjects are {student_names[i]}")
else:
print("No student passed all five subjects.")
elif choice ==9:
failedany = np.any(marks < 40,axis = 1)
failed_index = np.where(failedany)[0]
if len(failed_index)>0:
for i in failed_index:
print(f"{student_names[i]} failed in a subject ")
else:
print("No body Failed.")
elif choice ==10:
print("Have a good day!!")
break
else:
print("Please enter a number from above.")
except ValueError:
print("Please choose a whole number from above!!")