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