Palindrome Program In Python
Factorial Program In Python
Fibonacci Series Program
Armstrong Number Program In Python
Calculator Program
Patterns Program In Python
Leap Year Program
Prime Number Program In Python
Program To Find Area In Python
Program To Reverse A List
Palindrome Program In Python
def pal(num):
x1 = num[::-1]
if x1 == x:
print('palindrome')
else:
print('not a palindrome')
print(pal('edureka'))
-----------------------------
Factorial Program In Python
def fact(num):
if num == 0:
return num
else:
return num * fact(num - 1)
print(fact(5))
FIBONACCI SERIES
a = int(input('enter the first element'))
b = int(input('enter the second element'))
n = int(input('enter the number of elements '))
print(a,b, end=" ")
while n-2:
c = a + b
a = b
b = c
print(c, end=" ")
n = n-1
Following is the program to check whether a number is an armstrong
number or not.
num = int(input('enter the nuber'))
s = 0
temp = num
while temp &amp
0:
c = temp % 10
s += c**3
temp //= 10
if s == num:
print('armstrong number')
else:
print('not an armstrong number')
Calculator Program In Python
Following is the program to create a calculator
def add(a,b):
return a+b
def sub(a,b):
return a-b
def prod(a,b):
return a * b
def div(a,b):
return a / b
def si(p, r, t):
return (p*r*t) / 100
def ci(p, r ,t):
return p * pow((1 + r/100), t)
def sqr(num):
return num**2
def sqrt(num)
return num**0.5
print(add(10,15))
#to add two numbers, similarly you can use other functions for other operations.
Following is the program for patterns.
num = 5
a = (2 * num) - 2
for i in range(0, num):
for j in range(0, a ):
print(end=" ")
for j in range(0, i+1)
print('*' , end=" ")
print(" ")
# Program to find the sum of all numbers stored in a list
# List of numbers
numbers = [6, 5, 3, 8, 4, 2, 5, 4, 11]
# variable to store the sum
sum = 0
# iterate over the list
for val in numbers:
sum = sum+val
print("The sum is", sum)