0% found this document useful (0 votes)
4 views

1737947572371 CH9 Flow Control in Python.docx 1-1

The document covers flow control in Python, focusing on conditional statements such as if, if…else, and if…elif…else. It includes multiple-choice questions, fill-in-the-blanks, true/false statements, and short and long answer questions to explain the concepts. Additionally, it emphasizes the importance of indentation in Python for defining code structure.
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)
4 views

1737947572371 CH9 Flow Control in Python.docx 1-1

The document covers flow control in Python, focusing on conditional statements such as if, if…else, and if…elif…else. It includes multiple-choice questions, fill-in-the-blanks, true/false statements, and short and long answer questions to explain the concepts. Additionally, it emphasizes the importance of indentation in Python for defining code structure.
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/ 4

CLASS-VIII

SUBJECT - COMPUTER
CHAPTER– 9 (Flow Control in Python)
(Book Work)
A. Tick the correct option.
1.​ if…else
2.​ Hello
3.​ if a>=2:
4.​ if a>=2:
5.​ if (a==b): and if a==b: both are correct

B. Fill in the blanks.


1.​ Control
2.​ Conditional
3.​ if…elif…else
4.​ colon
5.​ else
6.​ if
C. Write T for True and F for False.
1.​ False
2.​ True
3.​ True
4.​ True
5.​ False
6.​ True

D. Short answer type questions.


1.​What do you understand by a conditional statement?
Ans. The statements which work on the basis of specified conditions are
called conditional statements. Conditionals are useful for decision-making as
each decision involves the choice between two alternatives i.e., true or false.

2.​Explain the use of if…else statements with an example.


Ans. If…else… statement is used in a situation when two actions are to be
performed on the basis of conditional expression outcome.
Example – Check if the user is eligible to vote or not.

3.​Differentiate between if…else statement and if…elif…else statement


with an example.
Ans. if…else statement is used in a situation when two actions are to be
performed on the basis of conditional expression outcome.
Example – Check if the user is eligible to vote or not.

if…elif…else statement is used when, we are stuck in a situation where


we might have more than one condition to choose. A single if…else
statement would not be sufficient in this case.
Example – Enter marks of three subjects. Calculate the average and display
grade of the student.
4.​What is Python indentation?
Ans. In Python, indentation refers to the use of spaces or tabs to indent lines
of code, defining the structure and grouping of statements.

5.​What are the different types of conditional statements used in Python?


Ans. Python supports the following types of conditional statements:
​ if Statement: Used to execute a block of code if a condition is true.
​ if-else Statement: Used to execute a block of code if a condition is true,
and another block if the condition is false.
​ if-elif-else Statement: Used to check multiple conditions and execute
different blocks of code accordingly.

E. Long answer type questions.


1.​Write a short note on conditional statements.
Ans. The statements which work on the basis of specified conditions are
called conditional statements. Conditionals are useful for decision-making as
each decision involves the choice between two alternatives i.e., true or false.

2.​Differentiate among if, if…else, if…elif…else statements. Explain your


answer with an example.
Ans.
if Statement: Used to execute a block of code if a condition is true.
Example – Check if the user is eligible to vote.

if…else statement is used in a situation when two actions are to be


performed on the basis of conditional expression outcome.
Example – Check if the user is eligible to vote or not.
if…elif…else statement is used when, we are stuck in a situation where
we might have more than one condition to choose. A single if…else
statement would not be sufficient in this case.
Example – Enter marks of three subjects. Calculate the average and display
grade of the student.

3.​Write a short note on:


a.​if statement​ ​ b. if…else statement​ c. if…elif…else
statement
Ans.
a.​if Statement: Used to execute a block of code if a condition is true.
b.​if-else Statement: Used to execute a block of code if a condition is true,
and another block if the condition is false.
c.​ if-elif-else Statement: Used to check multiple conditions and execute
different blocks of code accordingly.

4.​Explain indentation in Python with an example.


Ans. In Python, indentation refers to the use of spaces or tabs to indent lines
of code, defining the structure and grouping of statements.
Example:
if a>b:​ ​ ​ # if block starts here
​ print(a)​ ​ # This is part of the if block
else:​ ​ ​ # else must be at the same level as if
​ print(b)​ ​ # This line is part of the else block

You might also like