Slide 4
Slide 4 text
Interactive Fibonacci Sequence
Python Code Start Over Run Code
def fibonacci(n):
"""Calculate the Fibonacci sequence up to n terms."""
fib_sequence = [0, 1]
if n <= 0:
return []
if n == 1:
return [0]
# Generate Fibonacci sequence
1
2
3
4
5
6
7
8
9
10
⌄
⌄
⌄
First 10 Fibonacci numbers: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
Task: Try modifying the code to calculate more terms or implement a different algorithm!
PyCon Education Summit 2025