Area Perimeter Rectangle Circle coderinme

Area Perimeter Rectangle Circle coderinme

Area Perimeter Rectangle Circle.
To find the area and circumference of a circle with the given radius we use the following formulas:
Area of circle = PI * radius * radius
Circumference of circle = 2 * PI * radius
Similarly, to find the area and perimeter of a rectangle with the given length and breadth we use the following formulas:
Area of rectangle = length * breath
Perimeter of rectangle = 2 * ( length + breadth )

Program to calculate the area and perimeter of rectangle and area and circumference of circle.

#!/usr/bin/env python
import math
l=float(raw_input("Enter length of Rectangle: "))
b=float(raw_input("Enter breadth of Rectangle: "))
rad=float(raw_input("Enter radius of circle: "))
area_rect=l*b
peri_rect=2*(l+b)
print "\nlength of Rectangle is {} and breadth of Rectangle is {}".format(l,b)
print 'Area of Rectangle is: {} sq.units'.format(area_rect)
print "Perimeter of Rectangle is: {} units".format(peri_rect)
area_cir=math.pi*rad*rad
peri_cir=2*math.pi*rad
print "\nRadius of Circle is: {}".format(rad)
print "Area of Circle is: {:.2f} sq.units".format(area_cir)
print "Circumference of Circle is: {:.2f} units".format(peri_cir)

For more programs on Python, visit our Python Coder Archives

Area Perimeter Rectangle Circle coderinme

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

Leave a reply:

Your email address will not be published.