Question: # Author: [ Your Name ] # Program Description: This program records and calculates the pie eating times for contestants # in a speed eating
# Author: Your Name
# Program Description: This program records and calculates the pie eating times for contestants
# in a speed eating contest, providing average, fastest, and slowest times for each contestant
# and for the overall contest.
# Start Banner
print
printWelcome to Easy as Pie speed eating program"
print
# Input: Number of contestants
numcontestants intinputHow many contestants will be competing?
# Input: Number of pie eating attempts
numattempts intinputHow many attempts do all competitors get?
print
# Initialize overall statistics
totalattempts numcontestants numattempts
overallfastest floatinf # Start with infinity for comparison
overallslowest floatinf' # Start with negative infinity for comparison
overallsum # Sum of all times for average calculation
# Process each contestant
for contestant in range numcontestants :
printfContestant contestant Enter Eat Times"
print
fastesttime floatinf # Start with infinity for this contestant
slowesttime floatinf' # Start with negative infinity for this contestant
contestantsum # Sum of times for this contestant
# Record eating times for each attempt
for attempt in range numattempts :
time floatinputfEat Time attempt: What was the time for the attempt?
contestantsum time # Accumulate the sum of times
# Check for fastest and slowest times for this contestant
if time fastesttime:
fastesttime time
if time slowesttime:
slowesttime time
# Update overall fastest and slowest times
if time overallfastest:
overallfastest time
if time overallslowest:
overallslowest time
# Calculate average time for this contestant
averagetime contestantsum numattempts
# Display contestant statistics
print
printfEating Contestant contestant Time Summary"
print
printfHow many time attempts were recorded: numattempts
printfWhat was the average eating time for Eating Contestant contestant:
printfaveragetime:f seconds"
printfThe fastest eat time for Eating Contestant contestant was: fastesttime:f seconds"
printfThe slowest eat time for Eating Contestant contestant was: slowesttime:f seconds"
print
# Update overall sum for all contestants
overallsum contestantsum
# Calculate overall average time
overallaverage overallsum totalattempts
# Display overall summary
print
rewrite this code while using 'for in as a repetitive structure.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
