Page 74 - Code Craft Computer-8
P. 74
7 Python: Power-Up
Core Concepts
On completion of this chapter you will be able to know:
¨ The ‘For’ Statement ¨ The ‘While’ Statement
¨ Infinite Loop ¨ ‘Jump’ Statements
Warm Up #Problem Solving
Write a program in Python to multiply two numbers in the space given below.
_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________
Dear children! In the previous class, you learnt the basic concepts of Python, such as operators
and conditional statements. Now, you will learn about the iterative statements in detail. In a
program, there are many situations where we need to repeat same set of tasks again and again. In
Python, the statements that are used to repeat a set of instructions are called iterative or looping
statements. Looping statements are very useful and necessary for developing applications.
Python provides two types of looping statements :
1. for
2. while
Let’s discuss these constructs in brief.
THE FOR STATEMENT
The for statement executes a simple or compound statement for a fixed number of times. The
syntax of the for statement is given below:
for <variable> in <iterator>:
Statements
74

