133k views
2 votes
In this lab, you write a while loop that uses a sentinel value to control a loop in a Python program. You also write the statements that make up the body of the loop.

The source code file already contains the necessary assignment and output statements. Each theater patron enters a value from 0 to 4 indicating the number of stars that the patron awards to the Guide’s featured movie of the week. The program executes continuously until the theater manager enters a negative number to quit. At the end of the program, you should display the average star rating for the movie.

User Lorenzori
by
7.1k points

1 Answer

5 votes

Final answer:

To solve this lab, write a while loop in Python that uses a sentinel value to control the loop, prompt each patron to enter a star rating, and calculate the average star rating at the end.

Step-by-step explanation:

The subject of this question is Python programming.

To solve this lab, you would write a while loop that uses a sentinel value to control the loop. The sentinel value in this case is a negative number entered by the theater manager to quit the program. Inside the loop, you would prompt each theater patron to enter a value from 0 to 4, representing the number of stars they award to the featured movie. You would then keep track of the total number of stars and the number of patrons entered. Finally, you would calculate and display the average star rating by dividing the total number of stars by the number of patrons.

User Marquies
by
7.4k points