Advertisement
estefani-adriano

Is it possible to form a triangle? PYTHON

Oct 13th, 2023 (edited)
1,217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | Software | 0 0
  1. #Is it possible to form a triangle?
  2.  
  3. from time import sleep
  4. color = {'green' : '\033[4;32m', 'nothing' : '\033[m', 'red' : '\033[4;31m'}
  5.  
  6. print('         Analyzing a Triangle!        ')
  7. print('-=-' *15)
  8.  
  9. side1 = float(input('First side: '))
  10. side2 = float(input('Second side: '))
  11. side3 = float(input('Third side: '))
  12.  
  13. print('-=-' *15)
  14. print('LOADING...')
  15. sleep(2)
  16.  
  17. if (side1 < side2 + side3) and (side2 < side1 + side3) and (side3 < side1 + side2):
  18.     print('{}A triangle can be formed! c={}'.format(color['green'], color['nothing']))
  19. else:
  20.     print('{}A triangle cannot be formed! =c{}'.format(color['red'], color['nothing']))
  21.  
  22. #Mathematically, for three segments to form a triangle, the length of each side must be smaller than the sum of the other two.
  23.  
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement