1732718979674 Chapter 9 Control Structures in Python
1732718979674 Chapter 9 Control Structures in Python
Ans. A control structure is a programming construct which affects the flow of the execution of a
program.
Ans.We can use the if-elif- else statements to evaluate multiple scenarios. First it checks and evaluates
the first condition if it is true it will execute the respective statements, but if the condition is false it goes
to the elif statement and evaluates those conditions. Finally if none of the conditions evaluate to true it
executes the else block. The syntax of the if-elif-else statement is as follows:
if(conditional expression):
statement(s)
elif(conditional expression):
statement(s)
elif(conditional expression):
statement(s)
else:
statement(s)
(i) if statement
The if statement is a decision making statement that is used to control the flow of execution of
statements.
The syntax of the if statement is as follows:
if(conditional expression):
statement(s)
(iii)if-else
The if-else statement is used to evaluate whether a given statement is true or false.
if(conditional expression):
statement(s)
else:
statement(s)
Q4. How are sequential statements different from selection statements?
Ans. Sequential statements: The statements that are executed in a sequential order ie. one after the
other without any jumps are called sequential statements.
Selection statements: When programmers are required to execute a particular set of statements
depending on a particular test condition, a selection or decision making statement is required.
Ans.
(i)if statement:
(ii)if-else statement