Advertisement
Polyergic

Rewritine Online Python Tutor Example

Oct 2nd, 2012
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. # made for testing http://pythontutor.com/
  2. # derived from the example at http://pythontutor.com/ on 2012-Oct.-02
  3. # exceeds instruction limit when n>46
  4. n = 46
  5.  
  6.  
  7. def listMake(length):
  8.   r = None
  9.   c = length
  10.   while 0 < c:
  11.     r = ( c, r )
  12.     c = c - 1
  13.   return r
  14.  
  15. def listSum(numbers):
  16.   r = 0
  17.   q = numbers
  18.   while q:
  19.     (p,q) = q
  20.     r = r + p
  21.   return r
  22.  
  23.  
  24. myList = listMake(n)
  25. total = listSum(myList)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement