Open Amrivero-hub opened 7 months ago
def calculate_total_time(swimming_time, cycling_time, running_time): """ Calculates the total time taken to complete the triathlon.
Args:
swimming_time (float): Time taken for swimming (in minutes).
cycling_time (float): Time taken for cycling (in minutes).
running_time (float): Time taken for running (in minutes).
Returns:
float: Total time in minutes.
"""
return swimming_time + cycling_time + running_time
swimming_time = float(input("Enter the time for swimming (in minutes):")) cycling_time = float(input("Enter the time for cycling (in minutes):")) running_time = float(input("Enter the time for running (in minutes):"))
total_time = calculate_total_time(swimming_time, cycling_time, running_time)
if total_time <= 100: participant_award = "Provincial Colours" # Within the qualifying time (0 - 100 minutes) elif total_time <= 105: participant_award = "Provincial Half Colours" # Within 5 minutes of the qualifying time (101 - 105 minutes) elif total_time <= 110: participant_award = "Provincial Scroll" # Within 10 minutes of the qualifying time (106 - 110 minutes) else: participant_award = "No award"
print(f"The award that the participant will receive is {participant_award}.")
In this updated version:
I renamed swimming, cycling, and running to swimming_time, cycling_time, and running_time, respectively, for clarity. I also renamed award to participant_award to make its purpose more explicit.
Let’s improve the clarity of the triathlon program by renaming variables.