Robotics & Artificial Intelligence

Predict the output of the following code:

def Disp_Max(a, b):
    if a > b:
        print(a, 'is maximum')
    elif a == b:
        print(a, 'is equal to', b)
    else:
        print(b, 'is maximum')
Disp_Max(22, 14)

Python Functions

3 Likes

Answer

Output
22 is maximum
Explanation

The function Disp_Max() is called with the values 22 and 14. Inside the function, the condition a > b is checked first. Since 22 > 14 is True, the statement print(a, 'is maximum') gets executed and displays 22 is maximum. The elif and else blocks are skipped because the first condition is already satisfied.

Answered By

1 Like


Related Questions