-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathQuestion14.py
More file actions
33 lines (27 loc) · 767 Bytes
/
Copy pathQuestion14.py
File metadata and controls
33 lines (27 loc) · 767 Bytes
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
# Question
# 14. Write a program to input 3 sides of a triangle and prints whether it is an equilateral, isosceles or scale triangle.
#
# Code
#
sides = [int(input("Side "+str(n)+" :\n")) for n in range(3)]
s1, s2, s3 = sides #Too lazy to repeat the same thing. lol.
is_triangle = [s1+s2 > s3, s2 + s3 > s1, s3 + s1 > s2] #List of conditions to check
if all(is_triangle):
if s1 == s2 == s3:
print("Equivalent triangle")
elif s1 == s2 or s2 == s3 or s3 == s1:
print("isosceles triangle")
else:
print("Scalene triangle")
else:
print("Not a valid triangle!")
# Output:
# Side 0 :
# 6
# Side 1 :
# 6
# Side 2 :
# 6
# Equivalent triangle
#Additional Comments:
# all checks if all conditions r true from a list.