Robotics & Artificial Intelligence
In Python, an 'if-elif-else' can be used to implement the 'switch-case' paradigm.
Python Control Flow
2 Likes
Answer
True
Reason — In Python, the if-elif-else statement allows checking multiple conditions one after another, which performs the same role as a switch-case statement by executing different blocks of code based on different conditions.
Answered By
1 Like
Related Questions
Check that the following code snippet will execute properly or not. Justify your answer.
a=10 b=25 if a<b: print("a is less than b") else: print("b is less than a")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, 'elif' and 'else' can be used interchangeably.
The 'while' loop is suitable to iterate sequence data type.