Demo: Fibonacci function, in-browser editor, external grading

The Fibonacci numbers are 1, 1, 2, 3, 5, 8, ..., where each number is the sum of the two before it. These are numbered $F_1, F_2, \ldots$, and \[ F_n = F_{n-1} + F_{n-2}. \]

Write a Python function fib that takes a number n and returns the nth Fibonacci number, $F_n$.

Your code snippet should define the following variables:

Name Type Description
fib python function Function to compute the $n^\text{th}$ Fibonacci number
user_code.py

Note: In the above example, the attribute source-file-name='initial_code.py' was used to add existing code to the in-browser file editor from a source file. Another option is omit the source-file-name attribute and instead write the existing code directly inside the html element, between the pl-file-editor tags.

Correct answer

Student view placeholder

In student views this area is used for assessment and score info.
Tools

Staff information

Question

Title:
Demo: Fibonacci function, in-browser editor, external grading

Variant

Started at:
2026-09-19 08:00:26 (CDT)
Duration:
0s
Show/Hide answer
{}
History
dec frac
rad deg