BASIC PYTHON PROGRAMS FOR ABSOLUTE BEGINNERS
python program to calculate the area and perimeter of rectangle and area and circumference of circle.
LOGIC USED
Area of rectangle is length*breadth
Perimeter of rectangle is 2*(length+breadth)
Area of circle is pi*radius*radius
Perimeter of circle is 2*pi*radius
PROGRAM
l=int(input("enter the length of rectangle:"))
b=int(input("enter the breadth of rectangle:"))
r=int(input("enter the radius of the circle:"))
arear=float(l*b)
pr=float(2*(l+b))
pa=float(3.13*r*r)
p=float(2*3.14*r)
print('area of rectangle:',float(arear))
print('area of circle:',float(pa))
print("perimeter of rectangle:",float(pr))
print("perimeter of circle:",float(p))
b=int(input("enter the breadth of rectangle:"))
r=int(input("enter the radius of the circle:"))
arear=float(l*b)
pr=float(2*(l+b))
pa=float(3.13*r*r)
p=float(2*3.14*r)
print('area of rectangle:',float(arear))
print('area of circle:',float(pa))
print("perimeter of rectangle:",float(pr))
print("perimeter of circle:",float(p))
Input and output Of Program
enter the length of rectangle:4
enter the breadth of rectangle:4
enter the radius of the circle:4
area of rectangle: 16.0
area of circle: 50.08
perimeter of rectangle: 16.0
Tags:
codecademy