1import time
2tic = time.perf_counter() # Start Time
3your_program() # Your code here
4toc = time.perf_counter() # End Time
5# Print the Difference Minutes and Seconds
6print(f"Build finished in {(toc - tic)/60:0.0f} minutes {(toc - tic)%60:0.0f} seconds")
7# For additional Precision
8print(f"Build finished in {toc - tic:0.4f} seconds")
1import time, os
2
3seconds_to_go_for = 10 # How long the timer will go for
4current_time = int(time.time()) # Gets the time before the timer starts
5
6def clear():
7 if os.name == "nt":
8 os.system("cls") # Clear function, to avoid spam. Source: geeksforgeeks.org
9 else:
10 os.system("clear")
11
12while True:
13 time_now = int(time.time()) # Gets time during the timer's running
14 if time_now >= current_time + seconds_to_go_for: # Checks if enough time has passed
15 break # Stops loop if so
16
17 print(f"Seconds passed: {time_now - current_time}") # Prints how much time has passed
18 clear()
19print("The timer has ended")
1import time
2timer_length = float(input("How many seconds would you like you're timer to be set for? "))
3time.sleep(timer_length)
4print("Done!")
1import time
2import os
3
4a = int(0)
5b = int(0)
6
7while True:
8 print(str(b) + " minutes " + str(a) + " seconds")
9 a += 1
10 time.sleep(0.9999999)
11 if a == 59:
12 a = 0
13 b += 1
14 os.system('cls')