Chapter 8 Iterative Statements in Python
Brain Developers
A. Multiple Choice Questions:
1. Iterative statement is also known as ___________ statement.
a) Looping
b) Conditional
c) Selection
d) Sequential
Answer: a) Looping
2. The ______ loop is used when we are sure about how many times a loop body will be executed.
a) while
b) for
c) while…else
d) while…not…else
Answer: b) for
3. If the condition in a loop is false in the first step itself, we get ___________.
a) No output
b) Infinite
c) Error
d) Normal
Answer: a) No output
4. The ___________ operator checks whether a given value lies within a given set of values.
a) not in
b) between
c) range
d) in
Answer: d) in
5. The ___________ loop can be applied to a program where the number of iterations is not known beforehand.
a) while
b) while…else
c) for…not…else
d) for
Answer: a) while
B. Answer in one word:
1. Mention the other name for Iterative statements.
Answer: Loops or Looping statements
2. Name the two types of Iterative statements.
Answer: ‘for’ and ‘while’
3. Name the two membership operators in Python.
Answer: ‘in’ and ‘not in’
4. Which function is used to check the range in a loop?
Answer: range() function
C. Answer the following questions:
1. What do you mean by Iterative statements? Give examples.
Answer: The statements that keep repeating themselves as long as a given condition is true are called Iterative Statements or Repetitive Statements. As soon as the condition becomes false, the loop terminates. These are also called Looping statements or Loops.
2. Why are ‘for’ and ‘while’ loops called entry controlled loops?
Answer: The ‘for’ and ‘while’ loops called entry controlled loops because the condition statement is checked in the beginning of the loop.
3. What is the use of membership operators in Python?
Answer: Membership operators play an important role in controlling the working of a loop. There are two membership operators, ‘in’ and ‘not in’. Out of these, the ‘in’ operator is used with loops. The ‘in’ operator is used to check if a given value exists in the sequence or not. It evaluates to true if it finds a value in the specified sequence else returns false.
No comments:
Post a Comment