📑 Task
1) Explain the sequence of actions of this program2) Can you suggest an alternative code for timing only in Python?
📑 Answer
1) This code renders the countdown timer in the output areaof the Jupyter notebook or IPython environment
It based on Javascript and HTML components, stored in Python strings
2)
import time
from datetime import datetime
def timer(maxiter=100):
for i in range(maxiter):
time.sleep(1)
print(f"🕒 {(59 - datetime.now().second):0>2}",
flush=True, end='')
print("\r", flush=True, end='')
timer()
No comments:
Post a Comment