tryv while trueinput( laptime round(time time(lasttime totaltime round(time time(starttime print('lap #% % (% )(lapnumtotaltimelaptime)end=''lapnum + lasttime time time(reset the last lap time except keyboardinterrupthandle the ctrl- exception to keep its error message from displaying print('\ndone 'if the user presses ctrl- to stop the stopwatchthe keyboardinterrupt exception will be raisedand the program will crash if its execution is not try statement to prevent crashingwe wrap this part of the program in try statement we'll handle the exception in the except clause zso when ctrl - is pressed and the exception is raisedthe program execution moves to the except clause to print doneinstead of the keyboardinterrupt error message until this happensthe execution is inside an infinite loop that calls input(and waits until the user presses enter to end lap when lap endswe calculate how long the lap took by subtracting the start time of the laplasttimefrom the current timetime time( we calculate the total time elapsed by subtracting the overall start time of the stopwatchstarttimefrom the current time since the results of these time calculations will have many digits after the decimal point (such as )we use the round(function to round the float value to two digits at and at ywe print the lap numbertotal time elapsedand the lap time since the user pressing enter for the input(call will print newline to the screenpass end='to the print(function to avoid double-spacing the output after printing the lap informationwe get ready for the next lap by adding to the count lapnum and setting lasttime to the current timewhich is the start time of the next lap ideas for similar programs time tracking opens up several possibilities for your programs although you can download apps to do some of these thingsthe benefit of writing programs yourself is that they will be free and not bloated with ads and useless features you could write similar programs to do the following create simple timesheet app that records when you type person' name and uses the current time to clock them in or out add feature to your program to display the elapsed time since process startedsuch as download that uses the requests module (see intermittently check how long program has been running and offer the user chance to cancel tasks that are taking too long