Python ch-3 Questions Answers Full
Python ch-3 Questions Answers Full
Ans. A program’s control flow is the order in which the program’s code executes.
The control flow of a Python program is regulated by conditional statements,
loops, and function calls.
Ans. In Python, the selection statements are also known as Decision control
statements or branching statements.
The selection statement allows a program to test several conditions and execute
instructions based on which condition is true.
Some Decision Control Statements are:
❖ Simple if
❖ if-else
❖ nested if
❖ if-elif-else
(d) if – elif-else
(b) if –else
The if-else statement evaluates the condition and will execute the body of if if
the test condition is True, but if the condition is False, then the body of else is
executed.
(c) nested – if
Q.6 What do you mean by repetition statement in control flow structure? Write its
types.
❖ for loop
❖ while loop
Q.7 Explain for loop with an example.
Ans. In Python, while loops are used to execute a block of statements repeatedly until a
given condition is satisfied. Then, the expression is checked again and, if it is still
true, the body is executed again. This continues until the expression becomes false.
Q.9 What is a break statement? Write its example.
Ans. When a break statement is encountered inside a loop, the loop is immediately
terminated and the program control resumes at the next statement following the
loop.
Here, ‘Break’
statement will
stop printing
even numbers.
Ans. The continue statement works somewhat like a break statement. Instead of forcing
termination, it forces the next iteration of the loop to take place, skipping any code
in between.
Here, ‘Continue’
statement will be
showing the
continued value but
will skip the
condition.