Robotics & Artificial Intelligence

The function of 'else' in 'if-else' statement is:

  1. to execute the block of statements when the condition is True
  2. to execute the block of statements when the condition is False
  3. to specify an alternative condition
  4. None of these

Python Control Flow

1 Like

Answer

to execute the block of statements when the condition is False

Reason — In an if-else statement, when the condition written in the if statement evaluates to False, the else block is executed. Thus, the function of else is to execute the block of statements when the condition is False.

Answered By

2 Likes


Related Questions