All these programs has to be written in Theory note book(Both side ruled)
Students are advised to copy all the programs from the site
Every week new programs will be added
Sequence Structure Programming
1. Write a program to perform all the arithmetic operation with two variables
a=int(input("Enter a"))
b=int(input("Enter b"))
c=a+b
d=a-b
e=a*b
f=a/b
g=a%b
print("Sum ",c)
print("Difference ",d)
print("Product ",e)
print("Division ",f)
print("Modulus ",g)
2. Write a program to Calculate the Area and Perimeter of the Rectagle
l=int(input("Enter Length"))
b=int(input("Enter Breadth"))
a=l*b
p=2*l+b
print("Area ",a)
print("Perimeter ",p)
3. Write a program to calculate the Area and Circumference of the Circle
r=int(input("Enter Radius"))
a=3.142*r*r
c=2*3.142*r
print("Area ",a)
print("Circumference ",c)
4. Write a Program to Accept the time in seconds and display it in minute and seconds
s=int(input("Enter Time"))
m=s//60
rs=s%60
print("Minute ",m)
print("Remaining seconds ",rs)
5. Write a program to Accept the time in seconds and display it in hour, minute and seconds
s=int(input("Enter Time"))
h=s//3600
rs=s%3600
m=rs//60)
rs=s%60
print("Hour ",h)
print("Minute ",m)
print("Remaining seconds ",rs)
6. Write a program to Find the absolute, integer, float, round, minimum, maximum of a given number
n=float(input("Enter Number"))
print("Absolute ",abs(n))
print("Integer ",int(n))
print("float",float(n))
print("round",round(n,1))
print("minimum",min(n,123,12))
print("maximum",max(n,123,12))
7. Write a program to use all standard Mathematical Functions of Python
import math
n=int(input("Enter Number"))
print("Square Root ",math.sqrt(n))
print("e raised a power ",math.exp(n))
print("Natural Logarithm ",math.log(n))
print("Common Logarithm ",math.log10(n))
print("Square ",math.pow(n,2))
print("Cube ",math.pow(n,3))
print("Degrees ",math.degrees(math.pi/180))
print("Radians ",math.radians(180/math.pi*30))
print("Absolute value ",math.fabs(n))
Selection Structure Programming
8. Accept the age from the user and check whether he is eligible to vote or not
a=int(input("Enter Age"))
if a>=18 :
print("Eligible to vote")
else :
print("Not Eligible to vote")
9. Accept a number and Check whether the number is odd or even
n=int(input("Enter Number"))
if n%2==0 :
print("Even");
else :
print("Odd");
10. Accept a number and Check whether the number is divisible by 5 or not
n=int(input("Enter Number"))
if n%5==0 :
print("Divisible by 5")
else :
print("Not divisible by 5")
11. Accept a number and Check whether the number is a Buzz number or Not
n=int(input("Enter Number"))
if n%7==0 or n%10==7 :
print("Buzz Number")
else :
print("Not Buzz Number")
12. Accept a number and Check whether the number is a negative number, zero, positive number
n=int(input("Enter Number"))
if n<0 :
print("Negative Number")
elif n==0 :
print("Zero Number")
else :
print("Positive Number")
13. Accept the sides of a triangle and find the greatest side
a=int(input("Enter Side"))
b=int(input("Enter Side"))
c=int(input("Enter Side"))
if a>b and a>c :
print("A is the Greatest Side")
elif b>c and b>a :
print("B is the Greatest Side")
else :
print("C is the Greatest Side")
14. Accept sides of a triangle and check whether it is Equilateral, Isosceles, and Scalene Triangle
a=int(input("Enter Side"))
b=int(input("Enter Side"))
c=int(input("Enter Side"))
if a==b and a==c and b==c :
print("Equilateral Triangle")
elif a==b or b==c or c==a :
print("Isoceles Triangle")
else :
print("Scalene Triangle")
15. Accept three marks of a student. If average >= 40 declare Pass else Fail.
m1=int(input("Enter Mark1"))
m2=int(input("Enter Mark2"))
m3=int(input("Enter Mark3"))
av=(m1+m2+m3)/3
if av>=40:
print("Pass")
else:
print("Fail")
16. Accept three marks of a student and find out whether the student has passed or failed. If the individual mark is less than 40 declare fail. If average>=80 display Grade A if average>=60 display Grade B else Grade C
a=int(input("Enter Mark of First Subject"))
b=int(input("Enter Mark of Second Subject"))
c=int(input("Enter Mark of Third Subject"))
if a<40 or b<40 or c<40 :
print("Student has failed")
elif (a+b+c)/3 >80 :
print("Grade A")
elif (a+b+c)/3 >60 :
print("Grade B")
else :
print("Grade C")
17. Accept three numbers of a quadratic equation and find the nature of the Roots
a=int(input("Enter Number"))
b=int(input("Enter Number"))
c=int(input("Enter Number"))
if (a*b*b - 4*a*c) ==0 :
print("real and equal")
elif (a*b*b - 4*a*c) >0 :
print("real and non-zero")
else :
print("not real")
18. Accept cost & selling price and check whether he has made profit, loss, no profit no loss.
cp=int(input("Enter Cost Price"))
sp=int(input("Enter Selling Price"))
if sp>cp:
print("Profit")
elif cp>sp:
print("Loss")
else:
print("No Profit No Loss")
19. Accept a year and check whether it is a leap year or not.
y=int(input("Enter Year"))
if y%100==0:
if y%400==0:
print("Leap Year")
else:
print("Not Leap Year")
else:
if y%4==0:
print("Leap Year")
else:
print("Not Leap Year")
20. Accept three marks of a student. If any subject mark<40 declare Fail else Pass
m1=int(input("Enter Mark1"))
m2=int(input("Enter Mark2"))
m3=int(input("Enter Mark3"))
if m1<40 or m2<40 or m3<40:
print("Fail")
else:
print("Pass")
21. To calculate discount on the cost of purchased items, based on the following criteria
Cost Discount(In percentage)
Less than or equal to ₹ 10000 5 %
More than ₹ 10000 and less than or equal to ₹ 20000 10 %
More than ₹ 20000 and less than or equal to ₹ 35000 15 %
More than ₹ 35000 20%
cp=int(input("Enter the Cost Price"))
if cp<=10000:
dis = cp * 5/100
elif cp<=20000:
dis = cp * 10/100
elif cp<=35000:
dis = cp * 15/100
else :
dis = cp * 20/100
amount = cp - dis
print("The Selling Price after discount", amount)
22. Write a program to compute the tax according to the given conditions and display the output as per given format.
Total annual Taxable Income Tax Rate
Upto Rs. 1,00;000 No tax
From 1,00,001 to 1,50,000 10% of the income exceeding Rs. 1,00,000
From 1,50,001 to 2,50,000 Rs. 5,000 + 20% of the income exceeding Rs. 1,50,000
Above Rs. 2,50,000 Rs. 25,000 + 30% of the income exceeding Rs. 2,50,000.
taxincome=int(input("Enter the Taxable Amount"))
if taxincome<=100000 :
tax=0.0
elif taxincome<=150000 :
tax=.1*(taxincome-100000)
elif taxincome<=250000 :
tax=5000 + .2*(taxincome-150000)
else :
tax=25000 + .3*(taxincome-250000)
print("Tax to be paid = Rs.",tax)
23. The telephone department wishes to compute monthly telephone bills for its customers using the following rules. Minimum Rs. 250 for first 80 message units, plus 60 paisa per unit for next 60 units, plus 50 paisa per unit for next 60 units, plus 40 paisa per unit for any units above 200. Write a program that calculates the monthly bill, with input MESSAGE (the number of message units) and CUSTNO (the registration number of a customer). Then Display the bill in following format.
CUSTOMER NO :
MESSAGE UNITS :
AMOUNT (Rs.) :
customerNo=int(input("Enter Customer Number"))
Unit=int(input("Enter units"))
if Unit<= 80 :
bill = 250
elif Unit>80 and Unit<= 140 :
bill = 250+(Unit-80)*0.60
elif Unit>140 and Unit<= 200 :
bill = 250+36+(Unit-140)*0.50
elif Unit>200 :
bill = 250+36+30+(Unit-200)*0.40
print ("CUSTOMER NUMBER : ",customerNo)
print ("MESSAGE UNIT : ",Unit)
print ("BILL AMOUNT : ",bill)
24. A computer salesman gets commission on the following basis:
Sales Commission Rate
Rs. 0 - 20,000 5%
Rs. 20,000 - 50,000 10%
Rs. 50,001 and more 20%
After accepting the sales as input, calculate and print his commission amount and rate of commission.
sales=int(input("Enter Sales"))
if sales <= 20000:
rate = 5
commission = sales*.05
if sales> = 20001 and sales <= 50000:
rate = 10
commission = sales*.10
if sales> = 50001
rate = 20
commission = sales*.20
print("Commission Rate : ",rate,"%")
print("Commission Amount : ",commission)
25. Arithmetic menu driven Program.
print("1. Add two Numbers")
print("2. Subtract two Numbers")
print("3. Product two Numbers")
ch=int(input("Enter your choice"))
a=int(input("Enter A"))
b=int(input("Enter B"))
if ch==1:
print("Sum ",(a+b))
if ch==2:
print("Difference ",(a-b))
if ch==3:
print("Product ",(a*b))
26. Area menu driven Program.
print("1. Area of Square")
print("2. Area of Circle")
print("3. Area or Rectangle")
ch=int(input("Enter your choice"))
if ch==1:
s=int(input("Enter Side"))
a=s*s
print("Area of Square ",a)
if ch==2:
r=int(input("Enter Radius"))
a=3.142*r*r
print("Area of Circle ",a)
if ch==3:
l=int(input("Enter Length"))
b=int(input("Enter breadth"))
a=l*b
print("Area of Square ",a)