Posts

Showing posts with the label Conditional Statement

Conditional Statements:

Image
Python supports the following conditional statements: if statements if else statements elif statements else nested if…elif…else statements if statements:   Syntax for using the if keyword is as follows: i f [conditional expression]:     [statement(s) to execute] --> if keyword and the conditional expression is ended with a colon. In [conditional expression] some conditional expression is introduced that is supposed to return a boolean value, i.e., True or False. If the resulting value is True then the [statement to execute] is executed, which is mentioned below the if condition with a tabspace (This indentation is very important). if…else statements:   Syntax for using the if else keyword is as follows: if [test expression]:      [statement(s)] else:   [statement(s)] Example: Program to Read the Marks if…elif…else statements:  Syntax for using the if…elif…else statements is as follows: if[condi...