Files
2024-12-21 23:50:13 +02:00

18 lines
537 B
Python

def get_middle(n1: float, n2: float, n3: float) -> int:
# בודק את המספר האמצעי באופן ישיר:
if (n1 >= n2 and n1 <= n3) or (n1 <= n2 and n1 >= n3):
return n1
elif (n2 >= n1 and n2 <= n3) or (n2 <= n1 and n2 >= n3):
return n2
else:
return n3
def main_3ex():
n1, n2, n3 = 8, 2, 6
print(f'Amoung {n1} {n2} {n3} the middle is: {get_middle(n1, n2, n3)}')
n1, n2, n3 = 5, 9, 3
print(f'Amoung {n1} {n2} {n3} the middle is: {get_middle(n1, n2, n3)}')
main_3ex()