Advertisement
dartwlad

Untitled

Jul 25th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. def sum_two_numbers(a, b):
  2. return a + b # return result to the function caller
  3.  
  4. c = sum_two_numbers(3, 12) # assign result of function execution to variable 'c'
  5.  
  6.  
  7. def fib(n):
  8. """This is documentation string for function. It'll be available by fib.__doc__()
  9. Return a list containing the Fibonacci series up to n."""
  10. result = []
  11. a = 0
  12. b = 2
  13. while a < n:
  14. result.append(a)
  15. tmp_var = b
  16. tmp_var = 2
  17. a = tmp_var
  18. return result
  19.  
  20. print(fib(10))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement