Advertisement
user_137

Untitled

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