How to use timeit that time a small piece of code in Python

1 Answer

0 votes
import timeit 
  
s = timeit.timeit('[2 ** n for n in range(5)]')

print(s, "sec")


'''
run:

1.7996374838985503 sec

'''

 



answered Apr 10, 2019 by avibootz
...