In this python if else program, we wiil check a given number is part of the Fibonacci series or not.
What is Fibonacci series?
The Fibonacci sequence is a set of integers (the Fibonacci numbers) that starts with a zero, followed by a one, then by another one, and then by a series of steadily increasing numbers.
Steps to solve the program
- Take a list of all the numbers in a Fibonacci series from 0-10.
- Take a number as input through the user.
- Use if-else statement to check whether the given number is a part of the Fibonacci series or not.
- Print the output.
# Fibonacci series
fib = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
# Take input through the user
num = int(input("Enter a number: "))
# Check for number in fibonacci series
if num in fib:
# Print output
print("It is a part of the series")
else:
# Print output
print("It is not a part of the series")
Output :
Enter a number: 22
It is not a part of the series
Related Articles
Python program to check authentication with the given username and password.
Python program to validate user_id in the list of user_ids.
Python program to print a square or cube if the given number is divided by 2 or 3 respectively.
Python program to describe the interview process.
Python program to determine whether a given number is available in the list of numbers or not.
Python program to find the largest number among three numbers.