python area of rectangle code example
Example 1: area of a circle python
radius = float(input("Enter radius:"))
pi = 3.14
Area = pi * radius * radius
print("Area = " + str(Area))
Example 2: find the area of a circle in python
import math
radius = 3
area = math.pi * radius * radius
# another way would be to set variable and round - rounded_area = round(area, 3)
print(f'The area of the circle is {area:.3f}')
# round answer to 3 decimal places
Example 3: python area of rectangle
l = float(input('Enter the length of a Rectangle: '))
b = float(input('Enter the breadth of a Rectangle: '))
Area = l * b
print("Area of a Rectangle is: %.2f" %Area)