Advertisement
lucast0rres

Lista 2 - Item P em PYTHON

Apr 19th, 2016
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.51 KB | None | 0 0
  1. #This algorithm was crated by Lucas Pereira Torres de Araujo
  2. #Lista 2 - FUP's Class - 2016.1
  3. #Item P
  4.  
  5. from math import asin, pi
  6.  
  7. a = float(input("Digite o valor do lado A: "))
  8. b = float(input("Digite o valor do lado B: "))
  9. c = float(input("Digite o valor do lado C: "))
  10.  
  11. d1 = abs(b - c)
  12. d2 = abs(a - c)
  13. d3 = abs(a - b)
  14. d4 = (b + c)
  15. d5 = (a + c)
  16. d6 = (a + b)
  17.  
  18. if d1 < a and a < d4 and d2 < b and b < d5 and d3 < c and c < d6 :
  19.     print "Existe um triangulo cujos lados sao:", a, b, c
  20.  
  21.     global d8, d7, hip, cateto1, cateto2
  22.  
  23.     if a >= b and a >= c :
  24.         hip = a
  25.         cateto1 = b
  26.         cateto2 = c
  27.         d7 = ((cateto1*cateto1) + (cateto2*cateto2))
  28.         d8 = (hip*hip)
  29.  
  30.     elif b >= a and b >= c :
  31.         hip = b
  32.         cateto1 = a
  33.         cateto2 = c
  34.         d7 = ((cateto1*cateto1) + (cateto2*cateto2))
  35.         d8 = (hip*hip)
  36.  
  37.     elif c >= a and c >= b :
  38.         hip = c
  39.         cateto1 = a
  40.         cateto2 = b
  41.         d7 = ((cateto1*cateto1) + (cateto2*cateto2))
  42.         d8 = (hip*hip)
  43.  
  44.     if d8 == d7 :
  45.         print "E um triangulo retangulo = 90 graus."
  46.  
  47.         relacao1 = float(cateto1/hip)
  48.         x1 = float(asin(relacao1))
  49.         graus1 = float((x1*180)/pi)
  50.  
  51.         relacao2 = float(cateto2/hip)
  52.         x2 = float(asin(relacao2))
  53.         graus2 = float((x2*180)/pi)
  54.  
  55.         print "Os angulos (em graus) sao: 90,", graus1, graus2
  56.     else :
  57.         print "Nao e um triangulo retangulo."
  58. else :
  59.     print "Nao existe um triangulo cujos lados sejam:", a, b, c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement