Page 269 - Computer Science V2.0 Class 11
P. 269
That is followed by another suite, comprising a single statement at the next level of indentation:
print("Failed")
A conditional statement is executed when a particular condition specified in the header clause is satisfied. Conditional
statements and iterative statements are examples of compound statements. A compound statement has the following
components:
• A header clause, that begins with a keyword and ends with a colon.
• At the next indentation level, is a suite consisting of one or more Python statements.
In a Python program, indentation is of crucial importance. Make sure that all statements in a suite are indented at
the same level. Usually four spaces are used to write the code at next level of indentation.
10.2.3 pass Statement
In Python, the pass statement is ignored by the interpreter. Thus, it is a dummy statement. Often, it is used to leave
a slot for the code to be filled in later. Sometimes, it is also used to simplify program logic when no action is required
for a particular condition.
Syntax
pass
1. Identify the type of control flow for the following:
a. The set of statements are executed repeatedly.
b. The statements are executed in the same order as they are given in the program.
c. A set of statements will be executed if the given condition is True.
2. Name the following:
a. A dummy statement that is ignored by the interpreter.
b. A type of statement that has a header clause followed by a suite.
c. The character that ends a header clause.
10.3 Conditional Statements
As mentioned before, a conditional statement is a compound statement where the program flow depends on a
conditional expression. A conditional statement may also be referred to as a decision-making statement or branching
statement. There are three types of conditional statements in Python:
(i) if statement
(ii) if-else statement
(iii) if-elif ladder
10.3.1 if Statement
An if statement is the simplest compound statement that tests a condition. If the conditional expression yields True
on its evaluation, the sequence of statements following the if header clause is executed. As mentioned above, such a
sequence of statements is called a suite or an if-block. All statements in a suite are aligned at the same indentation
level and at a level next to the if header clause. However, if the conditional expression yields False, the suite
following the header is ignored by the interpreter.
Conditional Statements 255

