Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.
One possible program:
total = 0.0
count = 0
while True:
mark = float(input("Enter mark (-5 to finish): "))
if mark == -5:
break
if 50 <= mark <= 100:
count += 1
total += mark
if count > 0:
print("Average of valid marks:", total / count)
else:
print("No valid marks entered.")