MCPcopy Create free account
hub / github.com/geekcomputers/Python / angle_type

Function angle_type

Type of angles of a triangle.py:3–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1# This program will return the type of the triangle.
2# User has to enter the angles of the triangle in degrees.
3def angle_type():
4 angles = []
5
6 myDict = {
7 "All angles are less than 90°.": "Acute Angle Triangle",
8 "Has a right angle (90°)": "Right Angle Triangle",
9 "Has an angle more than 90°": "Obtuse Angle triangle",
10 }
11
12 print("**************Enter the angles of your triangle to know it's type*********")
13
14 angle1 = int(input("Enter angle1 : "))
15 if angle1 < 180 and angle1 > 0:
16 angles.append(angle1)
17 else:
18 print("Please enter a value less than 180°")
19 angle1 = int(input())
20 angles.append(angle1)
21
22 angle2 = int(input("Enter angle2 : "))
23 if angle2 < 180 and angle2 > 0:
24 angles.append(angle2)
25 else:
26 print("Please enter a value less than 180°")
27 angle2 = int(input())
28 angles.append(angle2)
29
30 angle3 = int(input("Enter angle3 : "))
31 if angle3 < 180 and angle3 > 0:
32 angles.append(angle3)
33 else:
34 print("Please enter a value less than 180°")
35 angle3 = int(input())
36 angles.append(angle3)
37
38 sum_of_angles = angle1 + angle2 + angle3
39 if sum_of_angles > 180 or sum_of_angles < 180:
40 print("It is not a triangle!Please enter valid angles.")
41 return -1
42
43 print("You have entered : " + str(angles))
44
45 if angle1 >= 90 or angle2 >= 90 or angle3 >= 90:
46 print(myDict.get("Has a right angle (90°)"))
47
48 elif angle1 < 90 and angle2 < 90 and angle3 < 90:
49 print(myDict.get("All angles are less than 90°."))
50
51 elif angle1 > 90 or angle2 > 90 or angle3 > 90:
52 print(myDict.get("Has an angle more than 90°"))
53
54
55angle_type()

Callers 1

Calls 2

appendMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected