Advertisement
user_137

Untitled

Sep 3rd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. def p0():
  2.     count = 0
  3.     phrase = "hello, world"
  4.     for iteration in range(5):
  5.         count  = len(phrase)
  6.         return ("Iteration {}; count is: {}".format(iteration, count))
  7.  
  8. def p1():
  9.     count = 0
  10.     phrase = "hello, world"
  11.     for iteration in range(5):
  12.         count  = len(phrase)
  13.         return ("Iteration "   str(iteration)   "; count is: "   str(count))
  14.  
  15. print(p0())
  16. print(p1())
  17. from timeit import timeit
  18. print(timeit('p0()', globals=globals())) # number=10
  19. print(timeit('p1()', globals=globals())) # number=10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement