๐Ÿ
B.TECH I YEAR โ€ข II SEMESTER โ€ข R25

Python Programming - Lab Manual

Python Programming Laboratory โ€ข Program Solution

๐Ÿ“˜ R25 Regulation ๐ŸŽ“ I Year ๐Ÿ“š II Semester ๐Ÿ Python Programming ๐Ÿงช Lab Program
Selected Program

geometrical shapes and operations

โ† All Python Programs

Aim:

☛   How do you make a module? Give an example of construction of a module using different geometrical shapes and operations on them as its functions.

Solution :


PROGRAM: (area.py)

 
from math import pi
def rectangle(l,b):
	return l * b
def square(s):
	return s * s
def circle(r):
	return pi * r * r
def triangle(l,b):
	return 1 / 2 * l * b


PROGRAM: (geometrical_shapes.py)

 
import area
l = int(input(" Enter value of height = "))
b = int(input(" Enter value of width = "))
s = int(input(" Enter value of side = "))
r = int(input(" Enter value of radius = "))

print(" Area of rectangle = " , area.rectangle(l,b))
print(" Area of square = " , area.square(s))
print(" Area of circle = " , area.circle(r))
print(" Area of triangle = " , area.triangle(l,b))

OUTPUT:

 
 Enter value of height = 6
 Enter value of width = 6
 Enter value of side = 6
 Enter value of radius = 6
 Area of rectangle =  36
 Area of square =  36
 Area of circle =  113.09733552923255
 Area of triangle =  18.0


๐Ÿ’ป Run This Python Program

geometrical shapes and operations
The selected Python program is loaded automatically into the editor. Edit the program, provide input if required and click Run.

The compiler is embedded using OneCompiler. Your Python program runs inside the embedded Python environment; Study Glance does not execute Python code directly on your web server.
โ† Back to Python Lab Programs ๐Ÿ“š All Lab Manuals