Question: This is PYTHON!!!!!!! the following code uses an infinite loop and a break statement that immediately causes control to exit the loop. This program can
This is PYTHON!!!!!!!
the following code uses an infinite loop and a break statement that immediately causes control to exit the loop. This program can be found in the file PartC_average_with_while.py
total = 0
counter = 0
while True: # an infinite loop
score = input("Enter a score (or -99 to exit): ") if score < 0:
break total += score counter += 1
print "Average is", float(total)/counter
Rewrite the above sentinel-controlled while loop without using a break statement.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
