Added task 3

This commit is contained in:
2024-12-21 23:50:13 +02:00
parent 94318de22d
commit 82ac1fcf4d
7 changed files with 133 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
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()