0% found this document useful (0 votes)
8 views

Python programs 2

The document contains four Python programs: one displays the multiplication table of 25 in reverse order, another lists the first 20 odd natural numbers, the third calculates the total surface area (TSA) and volume of a cube and cuboid, and the fourth computes the area and perimeter of a trapezium based on user input. Each program includes the code and sample output demonstrating its functionality. The programs utilize loops, conditional statements, and user input to perform calculations.

Uploaded by

utkarshyadav736
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Python programs 2

The document contains four Python programs: one displays the multiplication table of 25 in reverse order, another lists the first 20 odd natural numbers, the third calculates the total surface area (TSA) and volume of a cube and cuboid, and the fourth computes the area and perimeter of a trapezium based on user input. Each program includes the code and sample output demonstrating its functionality. The programs utilize loops, conditional statements, and user input to perform calculations.

Uploaded by

utkarshyadav736
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Programs

1.Write a program in Python to display table of 25 in reverse


order using for loop.

Program-

for i in range(10, 0, -1):

print(25 * i)

Output-

250

225

200

175

150

125

100

75

50

25

2.write a program in python to display first 20 odd natural


numbers in increasing order using while loop.

Program-

count = 0
number = 1

while count < 20:

print(number)

number += 2

count += 1

Output-

11

13

15

17

19

21

23

25

27
29

31

33

35

37

39

3.Write a program in python to display TSA and volume of


cube and cuboid.

Program-

side = float(input("Enter the side of the cube: "))

cube_tsa = 6 * (side ** 2)

cube_volume = side ** 3

print("Cube TSA:", cube_tsa)

print("Cube Volume:", cube_volume)

length = float(input("Enter the length of the cuboid: "))

width = float(input("Enter the width of the cuboid: "))

height = float(input("Enter the height of the cuboid: "))

cuboid_tsa = 2 * (length * width + width * height + height *


length)

cuboid_volume = length * width * height

print("Cuboid TSA:", cuboid_tsa)

print("Cuboid Volume:", cuboid_volume)


Output-

Enter the side of the cube: 4

Enter the length of the cuboid: 3

Enter the width of the cuboid: 2

Enter the height of the cuboid: 5

Cube TSA: 96.0

Cube Volume: 64.0

Cuboid TSA: 62.0

Cuboid Volume: 30.0

4.write a program in python to find area and perimeter of


trapezium using conditional statements (if-elif-else) as per
user's choice.

Program-

a = int(input("Enter the length of first parallel side: "))

b = int(input("Enter the length of second parallel side: "))

h = int(input("Enter the height of trapezium: "))

area = 0.5 * (a + b) * h

side1 = int(input("Enter the length of first side: "))

side2 = int(input("Enter the length of second side: "))

side3 = int(input("Enter the length of third side: "))

side4 = int(input("Enter the length of fourth side: "))


perimeter = side1 + side2 + side3 + side4

ch = input("Enter 'area' for area or 'perimeter' for perimeter: ")

if ch == "area":

print("Area of trapezium is", area)

elif ch == "perimeter":

print("Perimeter of trapezium is", perimeter)

else:

print("Invalid choice")

Output-

Enter the length of first parallel side: 5

Enter the length of second parallel side: 7

Enter the height of trapezium: 4

Enter the length of first side: 3

Enter the length of second side: 4

Enter the length of third side: 6

Enter the length of fourth side: 7

Enter 'area' for area or 'perimeter' for perimeter: area

Area of trapezium is 24.0

You might also like