In: Computer Science
For this problem, you should: describe the algorithm using a flowchart and then
write Python code to implement the algorithm.
You must include:
a.) a picture of the flowchart you are asked to create,
b.) a shot of the Python screen of your code, and
c.) a shot of the Python screen of your output.
Program Requirements: Your application will implement a stopwatch to be
used during a 1500-meter race in a swimming match. The input to the
application will be the number of seconds for two different swimmers
completing the race. Your application will determine the winner and output
their winning time in hours, minutes and seconds. Finally, if a swimmer broke
the record of 14:31 (fourteen minutes, 31 seconds) an additional message
should be printed.
#code
#method to convert seconds to a list containing hours, minutes and seconds
def secondsToHHMMSS(seconds):
hours=0
minutes=0
#converting seconds to hours
hours=int(seconds/(60*60))
#getting remaining seconds
extraSeconds=seconds%(60*60)
#converting remaining seconds to minutes
minutes=int(extraSeconds/60)
#getting remaining seconds
extraSeconds=extraSeconds%60
#defining a list containing hours,minutes and seconds
time=[hours,minutes,extraSeconds]
return time
#method to format a list containing time to HH:MM:SS format
def format_time(time):
return '{:02d}:{:02d}:{:02d}'.format(time[0],time[1],time[2])
#saving the current record time
record_time=[0,14,31]
winner_time=[]
#getting input seconds
seconds1=int(input("Enter running time of first swimmer (in seconds)"))
seconds2=int(input("Enter running time of second swimmer (in seconds)"))
#finding the running times
time1=secondsToHHMMSS(seconds1)
time2=secondsToHHMMSS(seconds2)
#checking for winner
if(seconds1 print("Swimmer 1 is the winner") winner_time=time1 elif(seconds1>seconds2): print("Swimmer 2 is the winner") winner_time=time2 else: winner_time=time2 print("It's a tie") print("Winning time:",format_time(winner_time)) # checking if the winner broke the current record if winner_time[0]<=record_time[0] and
winner_time[1]<=record_time[1] and
winner_time[2] print("Winner broke the current record time
of",format_time(record_time),"to set a new record
time",format_time(winner_time)) #code screenshot #output #flowchart