Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Prompt the user to enter 3 points on a standard Cartesian coordinate plane. You can assume the user will enter these values as floating -

Prompt the user to enter 3 points on a standard Cartesian coordinate plane. You can assume the user will enter these values as floating-point numbers.
Compute the distance between each pointsyou will be computing 3 distance values. The distance formula is below. Note that you can raise a value to the 0.5 power to compute the square root, or you can use the sqrt() function in the math module - your choice!
((x1-x2)^2+(y1-y2)^2)^0.5
Report the distance to the user of each side, rounded to 2 decimal places
Next, determine if the three points could form a valid triangle. You can assume that the triangle is valid by checking the following. Note that ALL THREE of these conditions must be met in order for a triangle to be valid:
-Side 1+ Side 2 must be longer than Side 3
-Side 2+ Side 3 must be longer than Side 1
-Side 3+ Side 1 must be longer than Side 2
If the triangle is valid, report whether it is an equilateral, isosceles, or scalene triangle:
-Equilateral Triangle: all sides of the triangle have the same length
-Isosceles Triangle: only two sides of the triangle have the same length
-Scalene Triangle: all sides of the triangle have different lengths
Hint: when comparing the size of each triangle it may be helpful to compare a rounded version of the length of each side. Due to floating point inaccuracies you may run into a where two values are virtually identical but Python will evaluate them to be different (i.e.0.000000001!=0.0). You can use the round() function. The round function takes in two arguments, the value you want rounded, and the amount of decimal places to round to. For example, round(3.14159,2)->3.14.
Extra Credit: Also report if the triangle is a right triangle (i.e. it has one angle of 90 degrees). You can do this by using the Pythagorean Theorem ( a2+ b2= c2) on the sides of the triangle
Hint: c(the hypotenuse) MUST be the largest side for the Pythagorean Theorem to work. Use an if statement to find the largest side and then test to see if the theorem holds.
Hint #2: round your numbers to 0 decimal points for the purpose of this calculation. For example, round(a2)+ round(b2)== round(c2)
Sample Runs: (Check graph for sample)
valid and invalid triangles
Enter Point #1- x position: 0
Enter Point #1- y position: 0
Enter Point #2- x position: 50
Enter Point #2- y position: 86.6
Enter Point #3- x position: 100
Enter Point #3- y position: 0
The length of each side of your test shape is:
Side 1: 100.00
Side 2: 100.00
Side 3: 100.00
This is a valid triangle!
This is an equilateral triangle
Enter Point #1- x position: 0
Enter Point #1- y position: 0
Enter Point #2- x position: 0
Enter Point #2- y position: 100
Enter Point #3- x position: 100
Enter Point #3- y position: 0
The length of each side of your test shape is:
Side 1: 100.00
Side 2: 100.00
Side 3: 141.42
This is a valid triangle!
This is an isosceles triangle.
This is also a right triangle.
Enter Point #1- x position: 110
Enter Point #1- y position: 100
Enter Point #2- x position: 75
Enter Point #2- y position: 25
Enter Point #3- x position: 0
Enter Point #3- y position: 0
The length of each side of your test shape is:
Side 1: 82.76
Side 2: 148.66
Side 3: 79.06
This is a valid triangle!
This is a scalene triangle
Enter Point #1- x position: 0
Enter Point #1- y position: 0
Enter Point #2- x position: 50
Enter Point #2- y position: 50
Enter Point #3- x position: 100
Enter Point #3- y position: 100
The length of each side of your test shape is:
Side 1: 70.71
Side 2: 141.42
Side 3: 70.71
This is not a valid triangle
Ensure that your program is well-commented, and that comments serve to document the logical flow of the program.
image text in transcribed

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

International Baccalaureate Computer Science HL And SL Option A Databases Part I Basic Concepts

Authors: H Sarah Shakibi PhD

1st Edition

1542457084, 978-1542457088

More Books

Students also viewed these Databases questions

Question

Assess three steps in the selection process.

Answered: 1 week ago

Question

Identify the steps in job analysis.

Answered: 1 week ago