Answers for "timing code python"

10

python time code

import time

t0 = time.time()
code_block
t1 = time.time()

total = t1-t0
Posted by: Guest on May-13-2020
0

python timing code

1# latest_tutorial.py
 2
 3import time
 4from reader import feed
 5
 6def main():
 7    """Print the latest tutorial from Real Python"""
 8    tic = time.perf_counter()
 9    tutorial = feed.get_article(0)
10    toc = time.perf_counter()
11    print(f"Downloaded the tutorial in {toc - tic:0.4f} seconds")
12
13    print(tutorial)
14
15if __name__ == "__main__":
16    main()
Posted by: Guest on July-07-2021
-1

python timer

import time
import os

a = int(0)
b = int(0)

while True:
    print(str(b) + " minutes " + str(a) + " seconds")
    a += 1
    time.sleep(0.9999999)
    if a == 59:
        a = 0
        b += 1
    os.system('cls')
Posted by: Guest on October-16-2020

Python Answers by Framework

Browse Popular Code Answers by Language