Answer to Question #298224 in Python for abhishek

Question #298224
  • Quiz 1 (20 marks - 10% Weight),
  • Quiz 2 (20 marks - 10% Weight),
  • Class test (50 marks - 25% Weight),
  • Assignment (100 marks - 25% weight) and
  • Project (200 marks - 30% weight).

Design a program that will prompt the user for marks for each of the tests and calculate the overall marks (out of 100).


1
Expert's answer
2022-02-15T15:11:11-0500
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!')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS