-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidation_student_results.py
88 lines (64 loc) · 2.13 KB
/
validation_student_results.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
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
data_valid = True
while data_valid:
grade1 = input("Type the grade of the first test: ")
try:
grade1 = float(grade1)
except ValueError as error:
print(f"Invalid input: {error}")
continue
if grade1 < 0 or grade1 > 10:
print("Grade should be between 0 and 10")
continue
else:
data_valid = False
data_valid = True
while data_valid:
grade2 = input("Type the grade of the second test: ")
try:
grade2 = float(grade2)
except ValueError as error:
print(f"Invalid input: {error}")
continue
if grade2 < 0 or grade2 > 10:
print("Grade should be between 0 and 10")
continue
else:
data_valid = False
data_valid = True
while data_valid:
total_classes = input("Type the total number of classes: ")
try:
total_classes = int(total_classes)
except ValueError as error:
print(f"Invalid input: {error}")
continue
if total_classes <= 0:
print("The number of classes can't be zero or less")
continue
else:
data_valid = False
data_valid = True
while data_valid:
absences = input("Type the number of absences: ")
try:
absences = int(absences)
except ValueError as error:
print(f"Invalid input: {error}")
continue
if absences < 0 or absences > total_classes:
print("The number of absences can't be less than zero or grater than the number of total classes")
continue
else:
data_valid = False
avg_grade = (grade1 + grade2) / 2
attendance = (total_classes - absences) / total_classes
print(f"Average grade: {round(avg_grade, 2)}")
print(f"Attendance rate: {str(round((attendance * 100), 2))}%")
if avg_grade >= 6 and attendance >= 0.8:
print("The student has been approved")
elif avg_grade < 6 and attendance < 0.8:
print("The student has failed due to an avarage grade lower than 6.0 and an attendance rate lower than 80%")
elif attendance >= 0.8:
print("The student has failed due to an average grade lower than 6.0")
else:
print("The student has failed due to an attendance rate lower than 80%")