This code defines a function called
largest
that takes three numbers as input and returns the largest one using an if-elif statement. The function can be tested by calling it with some example inputs and printing the output..# function to find the largest among three numbers
def largest(num1, num2, num3):
if (num1 >= num2) and (num1 >= num3):
largest_num = num1
elif (num2 >= num1) and (num2 >= num3):
largest_num = num2
else:
largest_num = num3
return largest_num
# test the function with some examples
print(largest(3, 4, 5)) # 5
print(largest(5, 4, 2)) # 5
print(largest(1, 1, 1)) # 1
0 yorum :
Yorum Gönder