Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def p0():
- count = 0
- phrase = "hello, world"
- for iteration in range(5):
- count = len(phrase)
- return ("Iteration {}; count is: {}".format(iteration, count))
- def p1():
- count = 0
- phrase = "hello, world"
- for iteration in range(5):
- count = len(phrase)
- return ("Iteration " str(iteration) "; count is: " str(count))
- print(p0())
- print(p1())
- from timeit import timeit
- print(timeit('p0()', globals=globals())) # number=10
- print(timeit('p1()', globals=globals())) # number=10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement