Leggi il codice attentamente
class Point:
__match_args__ = ("x", "y")
def __init__(self, x, y):
self.x = x
self.y = y
def describe(p):
match p:
case Point(0, 0):
return "origin"
case Point(0, y):
return f"y-axis:{y}"
case Point(x, y) if x == y:
return f"diag:{x}"
case Point(x, y):
return f"other:{x},{y}"
case _:
return "not_point"
print(describe(Point(0, 0)))
print(describe(Point(0, 5)))
print(describe(Point(3, 3)))
print(describe(Point(2, 7)))
print(describe("hello"))
Cosa stamperà il programma? Scrivi qui: