Add class for each prerelease
This commit is contained in:
@@ -1,16 +1,20 @@
|
||||
# define lists for all required data
|
||||
student_names = []
|
||||
test_1_marks = []
|
||||
test_2_marks = []
|
||||
test_3_marks = []
|
||||
total_marks = []
|
||||
# define number of students to record data for
|
||||
number_of_students = 30
|
||||
# define variable for storing total marks gained by all students overall
|
||||
sum = 0
|
||||
class Prerelease_047802:
|
||||
def __init__(self):
|
||||
Prerelease_047802.prerelease(self)
|
||||
def prerelease(self):
|
||||
# define lists for all required data
|
||||
student_names = []
|
||||
test_1_marks = []
|
||||
test_2_marks = []
|
||||
test_3_marks = []
|
||||
total_marks = []
|
||||
# define number of students to record data for
|
||||
number_of_students = 30
|
||||
# define variable for storing total marks gained by all students overall
|
||||
sum = 0
|
||||
|
||||
# function for prompting user for input, then checking it against conditions
|
||||
def getMark(test_number, student_index, max_mark):
|
||||
# function for prompting user for input, then checking it against conditions
|
||||
def getMark(test_number, student_index, max_mark):
|
||||
# keep asking for the mark until a valid mark is entered
|
||||
mark = None
|
||||
while not mark:
|
||||
@@ -29,13 +33,13 @@ def getMark(test_number, student_index, max_mark):
|
||||
# return mark
|
||||
return int(mark)
|
||||
|
||||
# do this for all students
|
||||
for i in range(number_of_students):
|
||||
# do this for all students
|
||||
for i in range(number_of_students):
|
||||
# retrieve and store student's name
|
||||
student_names.append(input("Student %d name: " % (i + 1)))
|
||||
|
||||
# do this for all students
|
||||
for i in range(number_of_students):
|
||||
# do this for all students
|
||||
for i in range(number_of_students):
|
||||
# retrieve and store student's test marks
|
||||
# test #1 has a max mark of 20
|
||||
test_1_marks.append(getMark(1, i, 20))
|
||||
@@ -48,9 +52,11 @@ for i in range(number_of_students):
|
||||
# add student's total marks to sum of all marks gained by all students overall
|
||||
sum += total_marks[-1]
|
||||
|
||||
# print each student's total marks
|
||||
for i in range(number_of_students):
|
||||
# print each student's total marks
|
||||
for i in range(number_of_students):
|
||||
print("%s: %d" % (student_names[i], total_marks[i]))
|
||||
|
||||
# print average total for all students
|
||||
print("Average total: %.2f" % (sum / 30))
|
||||
# print average total for all students
|
||||
print("Average total: %.2f" % (sum / 30))
|
||||
|
||||
Prerelease_047802()
|
||||
Reference in New Issue
Block a user