Question

IN PYTHON PLEASE Exercise #2: Design and implement a program (name it ComputeAreas) that defines four...

IN PYTHON PLEASE

Exercise #2: Design and implement a program (name it ComputeAreas) that defines four methods as follows:

Method squareArea (double side) returns the area of a square.

Method rectangleArea (double width, double length) returns the area of a rectangle.

Method circleArea (double radius) returns the area of a circle.

Method triangleArea (double base, double height) returns the area of a triangle.

In the main method, test all methods with different input value read from the user. Document your code and properly label the input prompts and the outputs as shown below.

Sample run:

Square side:    5.1

Square area:    26.01

Rectangle width:      4.0

Rectangle length:     5.5

Rectangle area:       22.0

Circle radius:        2.5

Circle area:          19.625

Triangle base:        6.4

Triangle height:      3.6

Triangle area:        11.52

0 0
Add a comment Improve this question Transcribed image text
Answer #1
import math
def  squareArea (side):
    return side*side

def rectangleArea (width, length):
    return width*length

def circleArea(radius):
    return math.pi*math.pow(radius,2)

def triangleArea (base, height):
    return (base*height)/2

side=float(input("Square side: "))
print("Square area: ",squareArea(side))

width=float(input("Rectangle width: "))
lenght=float(input("Rectangle lenght: "))
print("Rectengle Area: ",rectangleArea(width,lenght))

radius=float(input("circle radius: "))
print("Circle area: ",circleArea(radius))

base=float(input("triangle base: "))
height=float(input("triangle height: "))
print("Circle area: ",triangleArea(base,height))

Add a comment
Know the answer?
Add Answer to:
IN PYTHON PLEASE Exercise #2: Design and implement a program (name it ComputeAreas) that defines four...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT