Question

In: Computer Science

For this problem, you should: describe the algorithm using aflowchart and thenwrite Python code...

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.

Solutions

Expert Solution

#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


Related Solutions

construct A*star algorithm for solving the 8-puzzle problem . Use MATLAB or Python .Your code should...
construct A*star algorithm for solving the 8-puzzle problem . Use MATLAB or Python .Your code should include two heuristic functions -misplaced tiles and calculation of manhattan distance. The code should work for all cases of puzzle.
Write a python script to solve the 4-queens problem using. The code should allow for random...
Write a python script to solve the 4-queens problem using. The code should allow for random starting, and for placed starting. "The 4-Queens Problem[1] consists in placing four queens on a 4 x 4 chessboard so that no two queens can capture each other. That is, no two queens are allowed to be placed on the same row, the same column or the same diagonal." Display the iterations until the final solution Hill Climbing (your choice of variant)
In Python we will be using the below code for the problem: rainfile=open('rainfall.txt') for line in...
In Python we will be using the below code for the problem: rainfile=open('rainfall.txt') for line in rainfile: values = line.split() #print(values) print (values[0], 'had', values[1], 'inches of rain.') rainfile.close( ) The following is the text from rainfall.txt Akron 26.81 Albia 37.65 Algona 30.69 Allison 33.64 Alton 27.43 AmesW 34.07 AmesSE 33.95 Anamosa 35.33 Ankeny 33.38 Atlantic 34.77 Audubon 33.41 Beaconsfield 35.27 Bedford 36.35 BellePlaine 35.81 Belleveu 34.35 Blocton 36.28 Bloomfield 38.02 Boone 36.30 Brighton 33.59 Britt 31.54 Buckeye 33.66 BurlingtonKBUR...
Using python as the coding language please write the code for the following problem. Write a...
Using python as the coding language please write the code for the following problem. Write a function called provenance that takes two string arguments and returns another string depending on the values of the arguments according to the table below. This function is based on the geologic practice of determining the distance of a sedimentary rock from the source of its component grains by grain size and smoothness. First Argument Value Second Argument Value Return Value "coarse" "rounded" "intermediate" "coarse"...
Question 1: Using Python 3 Create an algorithm The goal is to create an algorithm that...
Question 1: Using Python 3 Create an algorithm The goal is to create an algorithm that can sort a singly-linked-list with Merge-sort. The program should read integers from file (hw-extra.txt) and create an unsorted singly-linked list. Then, the list should be sorted using merge sort algorithm. The merge-sort function should take the head of a linked list, and the size of the linked list as parameters. hw-extra.txt provided: 37 32 96 2 25 71 432 132 76 243 6 32...
Use Python to solve each problem. Answers should be written in full sentences. Define a code...
Use Python to solve each problem. Answers should be written in full sentences. Define a code that will give users the option to do one of the following. Convert an angle from radians to degrees, Convert an angle from degrees to radians, Return the sine, cosine, or tangent of a given angle (need to know if angle is given in degrees or radians).
Write code on python for Exponential Cooling Schedule Techniques of the SA algorithm to find the...
Write code on python for Exponential Cooling Schedule Techniques of the SA algorithm to find the shortest tour to visit all the cities according to TSP??
All code should be in Python 3. Implement the Stack Class, using the push, pop, str,...
All code should be in Python 3. Implement the Stack Class, using the push, pop, str, init methods, and the insurance variable 'list'.
Using Python code create a program only with beginners code. You are taking online reservations at...
Using Python code create a program only with beginners code. You are taking online reservations at the The inn Ask for your client’s name and save in a variable Ask how many nights your client will be staying and save in a variable Room rental is $145 per night Sales tax is 8.5% Habitation tax is $5 per night (not subject to sales tax) Print out: Client’s name Room rate per night Number of nights Room cost (room rate *...
The prompt is using Python:  Write a 3 rail transposition encryption algorithm, and a corresponding decryption algorithm....
The prompt is using Python:  Write a 3 rail transposition encryption algorithm, and a corresponding decryption algorithm. Implement these two algorithms in their own function. Now write a testing function that demonstrates your algorithms work for all interesting cases!
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT