# Functions
# Area of a shape
def fnSquare(s):
return (s*s)
def fnRectangle(l,b):
return (l*b)
def fnCircle(r):
return 3.142*r*r
def fnTriangle(base,ht):
return 0.5*base*ht
# square
s = eval(input("Enter side of square : "))
l,b = map(int,(input("Enter length and breath of rectangle : ").split()))
r = eval(input("Enter circle radius : "))
base,ht = map(int,(input("Enter base and height of triangle : ").split()))
print("Area of square =",fnSquare(s))
print("Area of rectangle =",fnRectangle(l,b))
print("Area of circle =",fnCircle(r))
print("Area of triangle =",fnTriangle(base,ht))
"""
Sample output
>python 6_Area.py
Enter side of square : 5
Enter length and breath of rectangle : 4 6
Enter circle radius : 3
Enter base and height of triangle : 5 6
Area of square = 25
Area of rectangle = 24
Area of circle = 28.278
Area of triangle = 15.0
"""
No comments:
Post a Comment
Don't be a silent reader...
Leave your comments...
Anu