हिंदी

What is the difference between the else and elif construct of the if statement? - Computer Science (Python)

Advertisements
Advertisements

प्रश्न

What is the difference between the else and elif construct of the if statement?

अंतर स्पष्ट करें

उत्तर

‘Else’ is used along with ‘if’ to define the alternative path if the condition mentioned in the ‘if’ statement is incorrect. This means that only one statement can be evaluated using the if..else statement.

If more than one statements need to be evaluated, the ‘elif’ construct is used. There is no limit on the number of ‘elif’ constructs that should be used in a statement. However, the conditions mentioned in each ‘elif’ construct should be mutually exclusive i.e. if one of the conditions in if..elif is correct it should imply that all the other conditions are false.

shaalaa.com
Introduction to Flow of Control - Selection
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 6: Flow of Control - Exercise [पृष्ठ १३९]

APPEARS IN

एनसीईआरटी Computer Science [English] Class 11
अध्याय 6 Flow of Control
Exercise | Q 1. | पृष्ठ १३९
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×