AMS 209: HW 4: Problem 7ΒΆ

 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
#!/usr/bin/env python3
# coding: utf8

'''
Created on October 31st, 2017

@author: Geetanjali
'''

def is_triangle(a, b, c):
	"""
	:param a, b, c: the lengths of the three sides of a triangle
	:return flag: is set to True if it is possible to form a triangle, else is set to False
	"""

	#To form a triangle, the sum of any two sides must be greater than or equal to the third side.
	flag = False

	if((a+b >= c) and (a+c >= b) and (b+c >= a)):
		flag = True 

	return flag


if __name__ == '__main__':

	print("Enter the length of the three sides a, b, and c of the triangle:")
	a = input("a = ")
	b = input("b = ")
	c = input("c = ")

	print("Is it possible to form a triangle with the values you entered? : "+str(is_triangle(float(a), float(b), float(c))))