Conditional Statements
Conditional Statements Block of Code A sequence of instructions are called block of code. Python executes code in a sequence. Condition An expression that results in either True or False Examples i. 2 < 3 ii. a == b iii. True Conditional Statement Conditional Statement allows you to execute a block of code only when a specific condition is True Conditional Block Block of code which executes only if a condition is True is called Conditional Block . Indentation Space(s) in front of the conditional block is called indentation . Indentation(spacing) is used to identify Conditional Block. Standard practice is to use four spaces for indentation. Possible Mistakes Each statement inside a conditional block should have the same indentation (spacing). Wrong Code 1 2 3 if True : print ( "If Block" ) print ( "Inside If" ) PYTHON Output IndentationError: unexpected indent Correct Code 1 2 3 if True : print ( "If Block" ) print ( ...