Robotics & Artificial Intelligence
The function of 'else' in 'if-else' statement is:
- to execute the block of statements when the condition is True
- to execute the block of statements when the condition is False
- to specify an alternative condition
- 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
3 Likes
Related Questions
Which of the following is the correct sequence to create multiple conditional statements?
- if else else
- if elif else
- if else elif
- if else if
Which logical operator(s) is/are used to combine multiple conditions in 'if' statement?
- and
- or
- not
- both a and b
How many conditions can be checked using the if-elif-elif-else statement?
- One
- Two
- Three
- Four
In Python, what would be the condition to check if a value is not equal to 5?
- x =! 5
- x != 5
- x not= 5
- x == 5