Untitled

 avatar
unknown
plain_text
2 years ago
2.6 kB
8
Indexable
Question 3
Write a program that receives from the user 3 numbers representing: exam score ([0-100]),
homework average ([0-100]), and number of exercises submitted (up to 8 exercises). The
program will calculate and display the final grade according to the following formula:
• If up to 4 total homework assignments are submitted, the final grade is 0 (failed).
• If 5 or 6 homework assignments were submitted: if the student passed the exam with a
grade of at least 55, the average of the homework assignments will be a valid 20% of the
final grade (see below for an explanation of what a "valid grade" is). If the student received
a grade of 54 or lower in the exam, the final grade will be the same as the exam grade.
• If 7 or 8 homework assignments were submitted:
o If the exam score is 54 or below:
- If the homework average is 80 or higher, then the homework constitutes 25%
shield.
- If the homework average is less than 80, then the homework constitutes 20%
shield.
o If the grade in the exam ranges from 55 to 100, the homework exercises make up
30% of the shield.
Note:
A “valid grade” means that the grade of the homework exercises will be weighted in any
case, even if it lowers the exam grade.
A “shield grade” means that the grade of the homework will be weighted if and only if it
raises the exam grade.                                                                                                              my implemtetion is'

exam_score = int(input("What is your exam score? "))
homework_average = float(input("What is your homework average? "))
exercise_submitted = int(input("How many exercises have you submitted? "))

if exercise_submitted > 8 or (exam_score < 0 or exam_score > 100) or (homework_average < 0 or homework_average > 100):
    print("Input out of range")
    exit()

if exercise_submitted <= 4:
    final_grade = 0
    
elif exercise_submitted == 5 or exercise_submitted == 6:
    if exam_score >= 55:
        final_grade = 0.8*exam_score + 0.2*homework_average
    else: exam_score <= 54
    final_grade = exam_score
    
else:
    exercise_submitted == 7 or exercise_submitted == 8
    if exam_score <= 54 and homework_average >= 80:
        final_grade = 0.25*homework_average + exam_score
    elif exam_score<= 54 and homework_average < 80:
        final_grade = 0.2*homework_average + exam_score
        
    
    else:
        exam_score >= 55 and exam_score <= 100
        final_grade = 0.3*homework_average + exam_score
        
if final_grade > 100:
    final_grade = 100
print("Your final grade is:", final_grade)
Editor is loading...
Leave a Comment