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("="*38)
print("Welcome to Easy as Pie speed eating program")
print("="*38)
# Input: Number of contestants
num_contestants = int(input("How many contestants will be competing?
"))
# Input: Number of pie eating attempts
num_attempts = int(input("How many attempts do all competitors get?
"))
print("--------------------------------------------------")
# Initialize overall statistics
total_attempts = num_contestants * num_attempts
overall_fastest = float('inf') # Start with infinity for comparison
overall_slowest = float('-inf') # Start with negative infinity for comparison
overall_sum =0 # Sum of all times for average calculation
# Process each contestant
for contestant in range(1, num_contestants +1):
print(f"Contestant {contestant}- Enter Eat Times")
print("--------------------------------------------------")
fastest_time = float('inf') # Start with infinity for this contestant
slowest_time = float('-inf') # Start with negative infinity for this contestant
contestant_sum =0 # Sum of times for this contestant
# Record eating times for each attempt
for attempt in range(1, num_attempts +1):
time = float(input(f"Eat Time {attempt}: What was the time for the attempt?
"))
contestant_sum += time # Accumulate the sum of times
# Check for fastest and slowest times for this contestant
if time < fastest_time:
fastest_time = time
if time > slowest_time:
slowest_time = time
# Update overall fastest and slowest times
if time < overall_fastest:
overall_fastest = time
if time > overall_slowest:
overall_slowest = time
# Calculate average time for this contestant
average_time = contestant_sum / num_attempts
# Display contestant statistics
print("==================================================")
print(f"Eating Contestant {contestant} Time Summary")
print("==================================================")
print(f"How many time attempts were recorded: {num_attempts}")
print(f"What was the average eating time for Eating Contestant {contestant}:")
print(f"{average_time:.1f} seconds")
print(f"The fastest eat time for Eating Contestant {contestant} was: {fastest_time:.1f} seconds")
print(f"The slowest eat time for Eating Contestant {contestant} was: {slowest_time:.1f} seconds")
print("--------------------------------------------------")
# Update overall sum for all contestants
overall_sum += contestant_sum
# Calculate overall average time
overall_average = overall_sum / total_attempts
# 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!