Triangolo equilatero
Senza operatori logici…
test = 0
if(a == b): test = test+1
if(b == c): test = test+1
if(test == 2): print("Equilatero")
if(test != 2): print("NON è equilatero")
oppure
test = 0
if(a != b): test = test+1
if(a != c): test = test+1
if(b != c): test = test+1
if(test == 0): print("Equilatero")
if(test != 0): print("NO equilatero")
oppure
if(a == b):
if(b == c):
print("Equilatero")
Con operatori logici
if(a == b) and (b == c):
print("Equilatero")
if not((a == b) and (b == c)):
print("NON è equilatero")
if(a != b) or (a != c) or (b != c):
print("NON è equilatero")
Triangolo scaleno
Senza operatori logici…
test = 0
if(a != b): test = test+1
if(a != c): test = test+1
if(b != c): test = test+1
if(test == 3): print("Scaleno")
if(test != 3): print("NON è scaleno")
oppure
test = 0
if(a == b): test = test+1
if(a == c): test = test+1
if(b == c): test = test+1
if(test == 0): print("Scaleno")
if(test != 0): print("NO scaleno")
oppure
if(a != b):
if(a != c):
if(b != c):
print("Scaleno")
Con operatori logici
if(a != b) and (a != c) and (b != c):
print("Scaleno")
if not((a != b) and (a != c) and (b != c)):
print("NON è scaleno")
if(a == b) or (a == c) or (b == c):
print("NON è scaleno")
Triangolo isoscele
Senza operatori logici…
test = 0
if(a == b): test = test+1
if(a == c): test = test+1
if(b == c): test = test+1
if(test == 1): print("Isoscele")
if(test != 1): print("NON è isoscele")
Con operatori logici
if(a == b) and (a != c): print("Isoscele")
if(a == c) and (a != b): print("Isoscele")
if(b == c) and (a != b): print("Isoscele")
oppure
if(a == b) and (a != c) or \
(a == c) and (a != b) or \
(b == c) and (a != b):
print("Isoscele")
Triangolo?
Senza operatori logici…
test = 0
if(a+b > c): test = test+1
if(a+c > b): test = test+1
if(b+c > a): test = test+1
if(test == 3): print("TRIANGOLO")
if(test != 3): print("NON è un triangolo")
oppure
if(a+b > c):
if(a+c > b):
if(b+c > a):
print("TRIANGOLO")
Con operatori logici
if(a+b > c) and (a+c > b) and (b+c > a):
print("TRIANGOLO")
if not((a+b > c) and (a+c > b) and (b+c > a)):
print("NON è un triangolo")
if(a+b <= c) or (a+c <= b) or (b+c <= a):
print("NON è un triangolo")