Robotics & Artificial Intelligence
In Python, 'elif' and 'else' can be used interchangeably.
Python Control Flow
1 Like
Answer
False
Reason — elif is used to check an additional condition, whereas else does not check any condition and is executed only when all the preceding if and elif conditions evaluate to false. Therefore, elif and else cannot be used interchangeably.
Answered By
1 Like
Related Questions
What would be the output of following code snippet:
a = [1, 2, 3, 4, 5] b = [2, 2, 2, 2, 2] for i in a: for j in b: k=i+j print(k)In Python, an 'if-elif-else' can be used to implement the 'switch-case' paradigm.
The 'while' loop is suitable to iterate sequence data type.
In Python, 'continue' and 'pass' keywords are interchangeable.