Python
placements
programs
Palindrome Program In Python
A palindrome is a number, string or a sequence which will be the same even after we
reverse the order. For example: MADAM, if spelled backwards will be same as MADAM.
Following is the python program to check whether the input string is a palindrome or
not.
1 def pal(num):
, 2 x1 = num[::-1]
3 if x1 == x:
4 print('palindrome')
5 else:
print('not a palindrome')
6
7
print(pal('edureka'))
8
Factorial Program In Python
Factorial of a number is the product of all the positive numbers less than or equal to the
number. The factorial of a number n is denoted by n!.
Following is the program to find the factorial of a number.
1 def fact(num):
2 if num == 0:
3 return num
4 else:
return num * fact(num - 1)
5
print(fact(5))
6
Fibonacci Series
A series in which the next term is the sum of the preceding two terms is called a
fibonacci series. Fibonacci series is asked frequently in interviews.
Following is a program to print a fibonacci series.
1 a = int(input('enter the first element'))
b = int(input('enter the second element'))
2 n = int(input('enter the number of elements '))
3 print(a,b, end=" ")
4
5 while n-2:
placements
programs
Palindrome Program In Python
A palindrome is a number, string or a sequence which will be the same even after we
reverse the order. For example: MADAM, if spelled backwards will be same as MADAM.
Following is the python program to check whether the input string is a palindrome or
not.
1 def pal(num):
, 2 x1 = num[::-1]
3 if x1 == x:
4 print('palindrome')
5 else:
print('not a palindrome')
6
7
print(pal('edureka'))
8
Factorial Program In Python
Factorial of a number is the product of all the positive numbers less than or equal to the
number. The factorial of a number n is denoted by n!.
Following is the program to find the factorial of a number.
1 def fact(num):
2 if num == 0:
3 return num
4 else:
return num * fact(num - 1)
5
print(fact(5))
6
Fibonacci Series
A series in which the next term is the sum of the preceding two terms is called a
fibonacci series. Fibonacci series is asked frequently in interviews.
Following is a program to print a fibonacci series.
1 a = int(input('enter the first element'))
b = int(input('enter the second element'))
2 n = int(input('enter the number of elements '))
3 print(a,b, end=" ")
4
5 while n-2: