Ch8-Iterative Statements in Python-Lead Notes

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Grade VIII

COMPUTER SCIENCE
Lead notes
Unit No:8
Name of the chapter: Iterative Statements in Python
Date: 03.03.2022 No. of pages: 2
NOTE –
➢ Write the Lead notes in your Computer Science CW.
➢ Submission date- 05.03.2022

1. Answer the following questions:

a) What do you mean by Iterative statements? Give examples.


Ans: 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 simply Loops.
The two types of Iterative statements used in Python are for loop and while loop.

b) Why are for and while loops called entry-controlled loops?


Ans: The for and while loops called entry-controlled loops because the condition statement is checked in
the beginning of the loop.

c) What is the use of membership operators in Python?


Ans: 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 it returns false.

d) Write the syntax of for and while loops.


Ans:
Syntax of for loop:
NPS.ITPL-2021/22/LN-CS
for <variable> in range (initial value, final value, step value):
Loop body (statements to be executed)

Syntax of while loop:


Initialization
while <Condition/ Test Expression>:
Loop body
Step value /updation

NPS.ITPL-2021/22/LN-CS

You might also like