Design a program that will prompt the user for marks for each of the tests and calculate the overall marks (out of 100).
print('What are your marks on Quiz 1?')
q1 = input()
print('What are your marks on Quiz 2?')
q2 = input()
print('What are your marks on Class test?')
classTest = input()
print('What are your marks on Assignment?')
assignment = input()
print('What are your marks on Project?')
project = input()
names = ['Quiz 1', 'Quiz 2', 'Class test', 'Assignment', 'Project']
maxMarks = [20, 20, 50, 100, 200]
weights = [0.1, 0.1, 0.25, 0.25, 0.3]
marks = []
if q1.isdigit() and q2.isdigit() and classTest.isdigit() and assignment.isdigit() and project.isdigit():
q1 = int(q1)
q2 = int(q2)
classTest = int(classTest)
assignment = int(assignment)
project = int(project)
marks.append(q1);
marks.append(q2);
marks.append(classTest);
marks.append(assignment);
marks.append(project)
status = True
for i in range(len(maxMarks)):
if marks[i] > maxMarks[i]:
status = False
print(f'You entered an invalid {names[i]} mark (need <= {maxMarks[i]})')
if status:
grade = 0;
for i in range(len(marks)):
grade += weights[i] * marks[i]
points = sum(marks)
print(f"You got {points} points, that's {round(grade, 1)}% of 100% possible")
else:
print('You are entering incorrect data, only integer are needed!')
Comments
Leave a comment