0% found this document useful (0 votes)
2 views3 pages

1732718979674 Chapter 9 Control Structures in Python

Chapter 9 discusses control structures in Python, focusing on the if-elif-else statement and its syntax for evaluating multiple conditions. It explains the if statement, nested if statements, and the if-else construct, highlighting their roles in controlling program execution flow. Additionally, it differentiates between sequential statements and selection statements in programming.

Uploaded by

vivaah148
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

1732718979674 Chapter 9 Control Structures in Python

Chapter 9 discusses control structures in Python, focusing on the if-elif-else statement and its syntax for evaluating multiple conditions. It explains the if statement, nested if statements, and the if-else construct, highlighting their roles in controlling program execution flow. Additionally, it differentiates between sequential statements and selection statements in programming.

Uploaded by

vivaah148
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CHAPTER 9

Control Structures in Python

Q1. What do you understand by control structure?

Ans. A control structure is a programming construct which affects the flow of the execution of a
program.

Q2. What is the use of if-elif-else statement? Write its syntax.

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)

Q3. Define and write the syntax of the following:

(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)

(ii) Nested if statement


Nested if statements mean if statements are placed within another if statement.
The syntax of the nested if statement is as follows:
if(conditional expression):
statement(s)
if(conditional expression):
statement(s)
elif(conditional expression):
statement(s)
else:
statement(s)
else:
statement(s)

(iii)if-else

The if-else statement is used to evaluate whether a given statement is true or false.

The syntax of the if-else statement is as follows:

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.

Q5.Draw the flowchart for the following statements.

Ans.
(i)if statement:
(ii)if-else statement

(iii) if-elif-else statement

(iv) Nested if statement

You might also like