CBSE Class 11 Computer Science Question 86 of 161

Flow of Control — Question 10

Back to all questions
10
Question

Question 10

What is the difference between else clause of if-else and else clause of Python loops?

Answer

The else clause of an if-else statement is executed when the condition of the if statement results into false. The else clause of a loop is executed when the loop is terminating normally i.e., when its test condition has become false for a while loop or when the for loop has executed for the last value in sequence.

Answer