Functions and methods

Functions and methods

Python functions or methods return or do not have to return values
1
def fib(n): # write Fibonacci series up to n
2
a, b = 0, 1
3
while a<n:
4
print(a, end=' ')
5
a,b = b,a+b
6
print("")
7
​
8
fib(10)
9
​
10
#0 1 1 2 3 5 8
Copied!
​
​
Last modified 1yr ago
Copy link