Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Python Fibonacci Sequence Generator

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Python Fibonacci Sequence Generator. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Implement a Python function that returns the first n numbers in the Fibonacci sequence as a list of integers. The sequence starts with 0, 1, and each later number is the sum of the previous two. If n is 0, return an empty list.

Constraints

  • 0 <= n <= 10^5
  • Return the first n Fibonacci numbers as a list
  • The sequence starts with 0, 1

Function Signature

def fibonacci_generator(n):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output