Advertisement
trds

25noiembrie2020

Dec 11th, 2020 (edited)
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.31 KB | None | 0 0
  1. def introducere() :
  2.     t = None
  3.     a = int(input("\na="))
  4.     b = int(input("\nb="))
  5.     c = int(input("\nc="))
  6.     t = (a, b, c)
  7.     return t
  8.  
  9.  
  10. def validare(t) :
  11.     if len(t) != 3 :
  12.         return False
  13.     if t[0] <= 0 or t[1] <= 0 or t[2] <= 0 :
  14.         return False
  15.     if t[0] + t[1] < t[2] :
  16.         return False
  17.     if t[0] + t[2] < t[1] :
  18.         return False
  19.     if t[1] + t[2] < t[0] :
  20.         return False
  21.     return True
  22.  
  23.  
  24. triunghi = introducere()
  25.  
  26. v = validare(triunghi)
  27.  
  28. if v == True :
  29.     print("Este triunghi")
  30. else :
  31.     print("Nu este triunghi")
  32.  
  33.  
  34. def echilateral(t) :
  35.     if t[0] == t[1] and t[1] == t[2] :
  36.         return True
  37.     else :
  38.         return False
  39.  
  40.  
  41. def isoscel(t) :
  42.     if t[0] == t[1] or t[0] == t[2] or t[2] == t[1] :
  43.         return True
  44.     else :
  45.         return False
  46.  
  47.  
  48. def dreptunghic(t) :
  49.     if t[0] * t[0] == t[1] * t[1] + t[2] * t[2] :
  50.         return True
  51.     if t[1] * t[1] == t[0] ** t[0] + t[2] * t[2] :
  52.         return True
  53.     return False
  54.  
  55.  
  56. def tip(t) :
  57.     if echilateral(t) == True :
  58.         return "echilateral"
  59.     if isoscel(t) == True :
  60.         return "isoscel"
  61.     if dreptunghic(t) == True :
  62.         return "dreptunghic"
  63.     return "oarecare"
  64.  
  65. t = tip(triunghi)
  66. print("triunghiul este {} este {}".format(triunghi, t))
  67.  
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement