give me stopwatch tool on python
- User
give me stopwatch tool on python
Assistant
Here's a simple Python stopwatch tool:
pythonimport time def stopwatch(): print("Stopwatch started. Press Ctrl+C to stop.") start_time = time.time() try: while True: elapsed = time.time() - start_time mins, secs = divmod(elapsed, 60) hours, mins = divmod(mins, 60) timer = f"{int(hours):02d}:{int(mins):02d}:{secs:06.3f}" print(timer, end="\r") time.sleep(0.01) except KeyboardInterrupt: print(f"\nStopwatch stopped at {timer}") if __name__ == "__main__": stopwatch()Would you like me to explain or break down this code?
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.