Question: Question C 3 [ 1 0 marks ] Write your answer in the provided file A 3 Q 3 . py . Fill in your
Question C marks
Write your answer in the provided file AQ py Fill in your name and student ID in the designated section.
Write a program based on the specifications below:
Define a Python Class based on the given simplified UML diagram and then given requirements:
Triangle
side
side
side
initside side side
str
isAtriangle
isRightAngleTriangle
area
a The constructor accepts three arguments for assigning related fields and define the data fields, properly assigning the input parameters accordingly.
b The method str returns a string representation of the object in the format shown in sample outputs.
c The method isAtriangle accepts no argument and returns True if the three input sides can form a triangle; returns False otherwise.
d The method isRightAngleTriangle accepts no argument and returns True if the triangle is a rightangle triangle; returns False otherwise.
e The method area accepts no argument, calculates the area of a triangle, and returns it
Write a function isSimilarTriangles to compare two triangles.
The function accepts two Triangle objects as input parameters and returns True if they are similar triangles; returns False otherwise.
Write a function main which continuously asks user to input values: sidea sidea sidea and sideb sideb sideb for the Triangle object T and T respectively. Formulate two triangles and continue the process until T and T are either similar triangles mathbfO R either one is a rightangle triangle.
a Exit the program when the triangles are similar triangles, or either one is a rightangle triangle. When both criteria are satisfied, display for similar triangles should be prioritized.
b If no two triangles are formed, display a message asking the user to reinitiate both triangles.
c If the triangles are neither similar triangles nor none of them is a rightangle triangle, display a message asking the user to reinitiate both triangles.
d You can assume that the user will only input valid numeric values.
Call the main to start to program execution.
Hint: Refer to the general guidelines to determine how to call the main function.
The program output should adhere to the Sample Program Output provided below: Sample Output :
Enter sidea for the first side of a triangle:
Enter sidea for the second side of a triangle:
gg Enter sidea for the third side of a triangle:
The sides and cannot form a triangle.
Enter sideb for the first side of a triangle:
Enter sideb for the second side of a triangle:
Enter sideb for the third side of a triangle:
The sides and can form a triangle with area
The two triangles are neither similar nor none of them being right angle triangle;
please reenter another two triangles.
This is a separator
Enter sidea for the first side of a triangle:
Note: In the last line of the Sample Output the program is still waiting for user input.
Sample Output :
Enter sidea for the first side of a triangle:
Enter sidea for the second side of a triangle:
Enter sidea for the third side of a triangle:
The sides and can form a triangle with area
Enter sideb for the first side of a triangle:
Enter sideb for the second side of a triangle:
Enter sideb for the third side of a triangle:
The sides and can form a triangle with area
At least one of the triangles are right angle triangle. Escape...!
Sample Output :
Enter sidela for the first side of a triangle:
Enter sidea for the second side of a triangle:
Enter sidea for the third side of a triangle:
The sides and can form a triangle with area
Enter sideb for the first side of a triangle:
Enter sideb for the second side of a triangle:
Enter sideb for the third side of a triangle:
The sides and can form a triangle with area
These two triangles are similar triangles. Escape...!
Note: The user inputs are in green.
END OF PAPER
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
