Added task 3
This commit is contained in:
17
basic programming/3rd task/3.py
Normal file
17
basic programming/3rd task/3.py
Normal 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()
|
||||
Reference in New Issue
Block a user