Ch-7 Control Strcuture in Python
Ch-7 Control Strcuture in Python
Book Exercise
1. Tick the correct option/ MCQ:
a. (ii) If, if-else
b. (i) if
c. (iii) break
d. (i) for
2. Fill in the blanks:
a. Control statement
b. Sequential
c. Conditional
d. Continue
3. Answer in one or two words:
a. Statements
b. If/ if-else/ if-elif-else
c. Range function
d. True condition
5. Application based questions:
a. Selection/ Conditional statements
b. for loop
Syntax:
for <variable_name> in <sequence/range>:
statement/s
c. break statement
6. Output of the python codes:
a. Output-
m is greater than 1
b. Please enter number
5
Sum is: 15
c. Output:
Total digits are: 1
Total digits are: 2
Total digits are: 3
Total digits are: 4
Total digits are: 5
Notebook Work:
Keywords:
1. Control Structure
2. Decision-making statement
3. if-elif-else statement
4. Iterative statement
5. Range function
6. Array manipulation
7. break statement
8. continue statement
9. Nested-if statement
10. Selection statement
Question-Answer:
1. What do you understand by control structure?
Ans- A control structure is a programming language construct which affects the flow
of execution of a program.
2. What is the if-elif-else statement used for? Write its syntax.
Ans- The if-elif-else statement is used to evaluate the multiple conditions. First, it
checks and evaluates the first condition. If it is true, it will execute the respective
statement(s), but if the condition is false, it goes the elif statement and evaluate
those conditions.
Finally, if none of the condition evaluates to true it executes the else block.
Syntax:
if (conditional expression):
statement(s)
elif (conditional expression):
statement(s)
elif (conditional expression):
statement(s)
else:
statement(s)
3. Write the syntax of the following:
(i) While loop
Ans- Syntax:
while (loop-condition):
statement(s)
(ii) Nested if statements
Ans- Syntax:
if (conditional expression):
statement(s)
if (conditional expression):
statement(s)
elif (conditional expression):
statement(s)
else:
statement(s)
else:
statement(s)
4. What are jump statements? Define the jump statements used in Python.
Ans- Jump statements are used to jump out of the loop iterations even if the
condition has not become false. They alter the flow of control unconditionally. The
jump statements defined in Python are break and continue.
-----------------------------------------------------------------------------------------------------------------