PYTHON PROGRAMS
7. WAP to find square of number 7.
number = 7
print("the square of 7 is =",number * number)
output-
8. WAP to find sum of two numbers 15 and
20
# Define the numbers
num1 = 15
num2 = 20
# Calculate the sum
sum = num1 + num2
# Print the result
print("The sum of", num1, "and", num2, "is:",
sum)
output-
9. WAP to print the table of 5 upto five
terms.
# Define the number
number = 5
# Print the table of 5 up to five terms
for i in range(1, 6):
print(number, "x", i, "=", number * i)
output-
10. Python program to find area and
circumference of a circle
r = int(input("Radius of circle"))
#circumference
circumference = 2 * 3.14 * r
print("circumference of circle is =",
circumference)
#area of circle
area = 3.14 * r * r
print("area of circle is =", area)
output-
11. WAP to calculate Simple Interest if the
principle_amount=2000,
rate_of_interest=4.5 and time=10
principle_amount = 2000
rate_of_interest = 4.5
time = 10
simple_interest = principle_amount *
rate_of_interest * time / 100
print("simple interest =", simple_interest)
output-
12. WAP to print the following pattern by
using multiple print commands
a. *
**
***
****
*****
b. * * * * *
****
***
**
*
# Pattern a
print("*")
print("* *")
print("* * *")
print("* * * *")
print("* * * * *")
#Pattern b
print("* * * * *")
print("* * * *")
print("* * *")
print("* *")
print("*")
output-
13. WAP to calculate Area and Perimeter of
a rectangle.
l = int(input("enter the length of rectangle"))
b = int(input("enter the breadth of rectangle"))
# area
area = l * b
print("Area of rectangle =", area)
# perimeter
perimeter = 2*(l + b)
print("Perimeter of rectangle =", perimeter)
output-
14. WAP to calculate Area of a triangle with
Base and Height.
b = int(input("Enter the base of triangle"))
h = int(input("Enter the height of triangle"))
area_of_triangle = 1/2 * b * h
print("The area of triangle is =",area_of_triangle)
output-
15. WAP to calculate average marks of 3
subjects.
a = int(input("enter the marks of english"))
b = int(input("enter the marks of A.I."))
c = int(input("enter the marks of hindi"))
average = a + b + c / 3
print("The average =", average)
output-
16. WAP to calculate surface area and
volume of cuboid.
l = int(input("Enter the length of cuboid"))
b = int(input("Enter the breadth of cuboid"))
h = int(input("Enter the height of cuboid"))
# area
surface_area = 2 * l * b + 2 * b * h + 2 * h * l
print("The surface area of cuboid is =",
surface_area)
# volume
volume = l * b * h
print("The volume of cuboid is =", volume)
output-
17. WAP to check if a person can vote.
age = int(input("Enter your age"))
if age > 18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")
output-
18. WAP to check the grade of student.
g = int(input("Enter your marks"))
if g==100:
print("you have scored grade A+")
elif g>=90 and g<100:
print(" you have scored grade A")
elif g>=80 and g<90:
print(" you have scored grade B")
elif g>=70 and g<80:
print(" you have scored grade C")
elif g>=60 and g<70:
print(" you have scored grade D")
elif g>=50 and g<60:
print(" you have scored grade E")
else:
print("you have scored grade F")
output-
19. WAP to input a number and check if the
number is positive, negative or zero and
display an appropriate message.
n = int(input("Enter a no. to check"))
if n>0:
print("The no. is positive")
elif n<0:
print("The no. is negative")
else:
print("The no. is zero")
output-
20. To print first 10 natural numbers
for i in range(1, 11):
print(i)
output-
21. To print first 10 even numbers
for i in range(2, 21, 2):
print(i)
output-
22. Create a list in Python of children
selected for science quiz with following
names- Arjun, Sonakshi, Vikram, Sandhya,
Sonal, Isha, Kartik. Perform the following
tasks on the list in sequence-
a) Print the whole list and delete the name
“Vikram” from the list
b) Add the name “Jay” at the end
c) Remove the item which is at the second
position.
l = ['Arjun' , 'Sonakshi' , 'Vikram' , 'Sandhya' ,
'Sonal', 'Isha' , 'Kartik']
print(l)
print("part a")
l.remove('Vikram')
print(l)
print("part b")
l.append('Jay')
print(l)
print("part c")
l.pop(1)
print(l)
output-