Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 4: Triangles In this problem, you have to create a class representing a triangle. A triangle is created specifying the lengths of its 3

Problem 4: Triangles
In this problem, 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 ,, , you have:
+
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.
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
the code im running says that the triangle is undefined. Also the test should say success under them to prove they are right
File Edit View Insert Runtime Tools Help All changes saved + Code + Text Problem 4: Triangles In this problem, 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. 1s_well_formed: Returns True if the triangle is well-formed, and false otherwise. A triangle is well formed if for edges of length x..., you have: * Sy+ 2 y in () 1 + 5 points well-formed. 2 ----> 3t = Triangle(3, 4, 5) 4 check_equal(t.is_well_formed(), True) 5 Os completed at 2:10 PM CSE_30_Winte....ipynb t = Triangle(3, 2, 2) check_equal(t.perimeter(), 7) D NameError Traceback (most recent call last) in 1 # 5 points: perimeter 2 3 t = Triangle(3, 4, 5) 4 check_equal(t.perimeter(), 12) 5 NameError: name 'Triangle' is not defined SEARCH STACK OVERFLOW [19] # 5 points: area t = Triangle(3,4,5) check_equal(abs(t.area() - 6)

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

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

2. (1 point) Given AABC, tan A b b

Answered: 1 week ago