Python program to find the average of final exam marks

Ask the user to provide final exam marks of 10 students in Introduction to Computing course in
order to calculate the average. Use while loop for this purpose, and use break statement to exit the
loop when an invalid input (e.g negative number) is given. Moreover, if marks greater than 100
are given, use continue statement to skip that number from average calculation.


# Ask the user to provide final exam marks of 10 students in Introduction to Computing course in  order to calculate the average. Use while loop for this purpose, and use break statement to exit the loop when an invalid input (e.g negative number) is given. Moreover, if marks greater than 100  are given, use continue statement to skip that number from average calculation.

student_marks = int(input('Enter the marks, use -1 to stop: '))
student_marks_counter = 1
total_marks = 0
while student_marks_counter <=10:
    student_marks = int(input('Enter the marks, use -1 to stop: '))
    if student_marks == -1:
        break
    if student_marks > 100:
        continue
    else:
        print('Student Marks = ', student_marks)
        total_marks += student_marks
        print('Total Marks', total_marks)
    student_marks_counter += 1
print('The average is', total_marks / 10 )

# This code is contributed by Ahmad Shafiq

callout-flag

Love this read? Subscribe to Modernage!

Do you have any queries? You can ask in the comments. We, at Modernage answer each and every question, asked in the comments, so If you have any queries, or you want to know about any specific platform you can ask in the comments below

Author

Leave a Reply

girl-carrying-document

More Articles.

SUBSCRIBE TO MODERNAGE

Top Posts

Author

SUBSCRIBE TO MODERNAGE

Technology

SUBSCRIBE TO MODERNAGE

Python

girl-carrying-document

More Articles.