1)Python program to check if a string is palindrome or not.
mystr = input(“Enter your string:”)
rev = mystr[::-1]
if mystr == rev:
print(“Palindrome”)
else:
print(“Not palindrome”)
2) Python program to find the sum of two numbers.
Source Code:
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
sum = a + b
print("Sum of”,a,”and”,b,”is”, sum)
3) Python program to check whether a number is even or odd.
Source Code:
num = int(input("Enter a number: "))
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")
4) Python program for printing Multiplication tables.
num = int(input ("Enter a number for the multiplication table: "))
print (num, "Tables\n")
for i in range(1, 11):
print (num, 'x', i, '=', num * i)
5) Python program To find the area of a circle
import math
r=5
area = [Link] * (r ** 2)
print(area)
6) Python program to count the occurrence of an element in a list
a = [1, 3, 2, 6, 3, 2, 8, 2, 9, 2, 7, 3]
count = 0
n=int(input(“Enter the number :”)
for val in a:
if val == n:
count += 1
print(count)
7) Python program to find the sum of elements in a list
arr = [12, 3, 4, 15]
sum = 0
for x in arr:
sum+= x
print('Sum:', t)
8) Python program to interchange the first and last elements in a list
lst = [1, 2, 3, 4, 5]
lst[0], lst[-1] = lst[-1], lst[0]
print( lst)