Answered step by step
Verified Expert Solution
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 points on a standard Cartesian coordinate plane. You can assume the user will enter these values as floatingpoint numbers.
Compute the distance between each pointsyou will be computing distance values. The distance formula is below. Note that you can raise a value to the power to compute the square root, or you can use the sqrt function in the math module your choice!
xxyy
Report the distance to the user of each side, rounded to 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 Side must be longer than Side
Side Side must be longer than Side
Side Side must be longer than Side
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 ie 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
Extra Credit: Also report if the triangle is a right triangle ie it has one angle of degrees You can do this by using the Pythagorean Theorem a b c on the sides of the triangle
Hint: cthe 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 #: round your numbers to decimal points for the purpose of this calculation. For example, rounda roundb roundc
Sample Runs: Check graph for sample
valid and invalid triangles
Enter Point # x position:
Enter Point # y position:
Enter Point # x position:
Enter Point # y position:
Enter Point # x position:
Enter Point # y position:
The length of each side of your test shape is:
Side :
Side :
Side :
This is a valid triangle!
This is an equilateral triangle
Enter Point # x position:
Enter Point # y position:
Enter Point # x position:
Enter Point # y position:
Enter Point # x position:
Enter Point # y position:
The length of each side of your test shape is:
Side :
Side :
Side :
This is a valid triangle!
This is an isosceles triangle.
This is also a right triangle.
Enter Point # x position:
Enter Point # y position:
Enter Point # x position:
Enter Point # y position:
Enter Point # x position:
Enter Point # y position:
The length of each side of your test shape is:
Side :
Side :
Side :
This is a valid triangle!
This is a scalene triangle
Enter Point # x position:
Enter Point # y position:
Enter Point # x position:
Enter Point # y position:
Enter Point # x position:
Enter Point # y position:
The length of each side of your test shape is:
Side :
Side :
Side :
This is not a valid triangle
Ensure that your program is wellcommented, and that comments serve to document the logical flow of the program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started