Python program to print Fibonacci series

Description: Write a Python program to print the first 10 numbers of the Fibonacci series.

Rules and hints:

  • Each number is the sum of the two numbers before it.
  • The series starts with 0 and 1.

Python program for Fibonacci series

a, b = 0, 1

for _ in range(10):
    print(a, end=" ")
    a, b = b, a + b

Output:

Tutorials Class - Output Window

0 1 1 2 3 5 8 13 21 34

How it works

  • a and b hold two neighbour numbers of the series.
  • print(a, end=" ") prints on the same line with a space.
  • a, b = b, a + b moves to the next pair at once.
  • The loop variable _ means we do not use its value.

Learn more about the similar topics:
Tutorials
Python Conditional Statements
Python While Loop
Python for loop
Python Jump Statements
Exercises & Assignments
Python program to check even or odd number
Python program to find the largest of three numbers
Python program to check leap year
Python program to print multiplication table
Python program to find factorial of a number
Python program to print Fibonacci series
Python program to check prime number
Interview Questions & Answers
No Content Found.