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