-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrading.py
45 lines (43 loc) · 1.15 KB
/
grading.py
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
'''
Program: WAP to input marks of 5 subject and find average and assign grade.
Average Marks Grade
90 & above O
80 – 89 E
70-79 A
Below 70 B
Author: Bikramadittya Bagchi
Date: 02-02-2021
'''
# Declarations
marks_list = []
total = 0.0; avg = 0.0
# Taking input from user
while True:
for i in range(5):
try:
usr_inp = input("Please enter a marks: ")
usr_inp = float(usr_inp)
if usr_inp >= 0 and usr_inp <= 100:
marks_list.append(usr_inp)
else:
print("Entered marks not in range of 0 and 100! Skipping this entry")
except ValueError:
print("Invalid data entered! Please enter a valid marks")
break
else:
break
if len(marks_list) == 5:
for i in range(5):
total += marks_list[i]
avg = total/len(marks_list)
print(f"Average marks is {avg}")
if avg >= 90:
print("Grade is O")
elif avg >= 80:
print("Grade is E")
elif avg >= 70:
print("Grade is A")
else:
print("Grade is B")
else:
print("Incomplete data provided!")