PYTHON PROGRAMS
1. Absolute Difference
a=int(input(“Enter the first integer:”))
b=int(input(“Enter the second integer:”))
print(abs(a-b))
2. Area of Square
a= int(input(“Enter the length of the side:”))
print(“The area is:”, a*a)
3. Area of Rectangle
l=int(input(“Enter length:”))
b=int(input(“Enter breadth:”))
print(“The area is :”, l*b)
4. Perimeter of Triangle
p=eval(input(“First side:”))
q=eval(input(“Second side:”))
r=eval(input(“Third side:”))
print(“Perimeter is:”, p+q+r)
5. Simple Interest
P=eval(input(“Enter Principal amount:”))
T=eval(input(“Enter time:”))
R=eval(input(“Enter rate of interest:”))
Print(“Simple Interest:”, (P*T*R)/100)
6. Program for Mark Scenario
marks=int(input(“Enter the marks”))
if marks > 80:
if marks > 90:
print(“prize: Rs.2000”)
elif marks <=90:
print(“prize: Rs. 1800”)
elif marks > 68:
if marks> 75:
print(“ prize: Rs. 1400”)
elif marks <=75:
print(“Prize : Rs. 1100”)
elif marks > 60:
print(“Prize: Rs. 800”)
7. Display All even numbers in a Range
n=int(input(“Enter upperlimit of range:”))
for i in range(2, n+1, 2):
print(i)
8. Display all prime numbers in a range
n1=int(input(“Enter the start value:”))
n2=int(input(“Enter the end value:”))
print(“The prime numbers between”,n1”,and”,n2”,are:”)
for num in range(n1, n2+1)
if(num>1):
for i in range(2, num):
if(num%i==0):
break
else:
print(num)
9. Minimum and Maximum value in a list
L1 = [1,2,100,50,62,121,59,5]
print(“The minimum value is:”, min(L1))
print(“The maximum value is:”, max(L2))
10. Palindrome of a String.
string1=input(“Enter the string:”)
If string 1 == string1[::-1]:
print(“It is palindrome”)
else:
print(“It is not a palindrome”)