Hi,
I could see a bug in the Modules section page of Tutorial
https://docs.python.org/3/tutorial/modules.html
Below are the modules in Fibo.py
# Fibonacci numbers module
def
fib(n):
# write Fibonacci series up to n
a, b
=
0,
1
while b
< n:
print(b, end='
')
a, b
= b, a+b
print()
def
fib2(n):
# return Fibonacci series up to n
result
= []
a, b
=
0,
1
while b
< n:
result.append(b)
a, b
= b, a+b
return result
The problem is with the below section:
Fib2(100) doesn’t print the data, it just returns the data. So it will first have to be assigned to a variable and then can print that variable.
>>> fibo.fib(1000)
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
>>> fibo.fib2(100)
[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
>>> fibo.__name__
'fibo'
Regards,
Pratik Surani
07565987160