Question
Python Coding Assignment: Create a code to get the following output. Add (#) comments to line of code for explanation A triathlon is an athletic
Python Coding Assignment: Create a code to get the following output. Add (#) comments to line of code for explanation
A triathlon is an athletic contest consisting of three different events, typically swimming, cycling, and longdistancing running. Write a program that will prompt and accept the number of participants in a triathlon whose data is to be presented. For example (Interaction):
How many participants do you wish to display? 2 Name: Jeff Adrian Division: M4044 Event: Standard Triathlon: 1.5km Swim, 40km Bike, 10km Run Gender: Male Swim: 33.77 minutes Transition 1: 5.48 minutes Bike: 77.08 minutes Transition 2: 0.58 minutes Run: 64.12 minutes Total: 181.03 minutes Name: Jacob Adserballe Division: M4549 Event: Standard Triathlon: 1.5km Swim, 40km Bike, 10km Run Gender: Male Swim: 29.47 minutes Transition 1: 3.73 minutes Bike: 70.35 minutes Transition 2: 0.23 minutes Run: 48.03 minutes Total: 151.82 minutes
Notice that all the times are displayed to two (2) significant digits
****needs to be in Python and needs a getPosInt(prompt) function and secToMin(s) function****
I have prefilled function arrays with first and last names, and times for events, genders, transition times. just need to know where to put the info in the input and output
## Main entry point of program def main(): # declare parallel arrays and populate with data lastName = getLastNames() # holds the last names of the participants firstName = getFirstNames() # holds the first names of the participants division = getDivisions() # holds the age group assignment for standard and sprint swimTimes = getSwimTimes() # holds the swim times in seconds transition1Times = getT1Times() # holds the transition I times in seconds cycleTimes = getCycleTimes() # holds the cycling times in seconds transition2Times = getT2Times() # holds the transition II times in seconds runTimes = getRunTimes() # holds the runTimes in seconds event = getEvent() # holds the event id. 1 = standard tri, 2 = sprint tri gender = getGender() # holds the gender of the participant
numToDisplay = 0 # holds the number of participants to display ttl = 0 # total time accumulator in loop
############################################################# # Complete the following line of code for max array length ############################################################# numOfParticipants = len(getLastNames()) # holds the max index number for the arrays
### input phase # Use a while loop to ask user how many participants they want to display # if the response is too large, print "Your entry exceeds the number of participants! Please try again!" while True: inp= int(input("How many participants do you wish to display? ")) if inp>numOfParticipants: print("Your entry exceeds the number of participants! Please try again!") else:
for i in range(len(numOfParticipants)):
### output phase # output the demographic information: First and Last Name, Division, Event, and Gender # output the time metrics
### call main to run program main() this is the the code I have so far
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started