Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Is it possible to form a triangle?
- from time import sleep
- color = {'green' : '\033[4;32m', 'nothing' : '\033[m', 'red' : '\033[4;31m'}
- print(' Analyzing a Triangle! ')
- print('-=-' *15)
- side1 = float(input('First side: '))
- side2 = float(input('Second side: '))
- side3 = float(input('Third side: '))
- print('-=-' *15)
- print('LOADING...')
- sleep(2)
- if (side1 < side2 + side3) and (side2 < side1 + side3) and (side3 < side1 + side2):
- print('{}A triangle can be formed! c={}'.format(color['green'], color['nothing']))
- else:
- print('{}A triangle cannot be formed! =c{}'.format(color['red'], color['nothing']))
- #Mathematically, for three segments to form a triangle, the length of each side must be smaller than the sum of the other two.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement