KnowledgeBoat Logo
|

Robotics & Artificial Intelligence

What will be the output of the following statement for any two values of a & b entered by the user?

print(a) if a>b else print(b)

  1. It will give an error
  2. It will print the largest number
  3. It will print the smallest number
  4. None of these

Python Control Flow

1 Like

Answer

It will print the largest number

Reason — This is a shorthand if-else statement. If the condition a > b is true, the value of a is printed, otherwise, the value of b is printed. Therefore, the larger of the two numbers is printed.

Answered By

3 Likes


Related Questions