Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

you have to create a class representing a triangle. A triangle is created specifying the lengths of its 3 sides; for instance, Triangle(3, 4, 5)

you have to create a class representing a triangle. A triangle is created specifying the lengths of its 3 sides; for instance,

Triangle(3, 4, 5)

creates a triangle with sides 3, 4, 5.

The class has to implement the following methods.

  • is_well_formed: Returns True if the triangle is well-formed, and false otherwise. A triangle is well formed if, for edges of length x,y,z, you have:

xy+zy

  • perimeter: Returns the perimeter of the triangle.

  • area: Returns the area of the triangle, using Heron's formula.

We give you the class skeleton, and you have to complete the methods.

# This may be useful to compute square roots...

import math

class Triangle(object):

def __init__(self, x, y, z):

"""Creates a triangle of sides x, y, z"""

# YOUR CODE HERE

raise NotImplementedError()

def is_well_formed(self):

"""Returns True if the triangle is well-formed, and false otherwise."""

# YOUR CODE HERE

raise NotImplementedError()

def perimeter(self):

"""returns the perimeter of the triangle."""

# YOUR CODE HERE

raise NotImplementedError()

def area(self):

"""Returns the area of the triangle."""

# YOUR CODE HERE

raise NotImplementedError()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions

Question

4. Did you rethink your decision?

Answered: 1 week ago

Question

3. Did you seek anyones advice?

Answered: 1 week ago

Question

7. What traps should she avoid?

Answered: 1 week ago