Computer _G8
Computer _G8
ample 9.
rstand the prograJ!l cod
L~t us unde
Program cod e
The var iable an s gets the value 1.
.
an s is l.
an s= l This loop will continue till
ut.
wh ile (an s= =l) : The program will ask for inp
yp e th e Pa ss wo rd :") )
pa ss wo rd =in t (in pu t ("T only
The value of an s will change
i f {pa ss wo rd= =1 23 4) : when the password is correc
t.
ans=O
fore, such a
for ev er if the pa~ssword entered is incorrect. There
e
Notice, the loop will continu
p.
loop is called an infinite loo
·• ..
f)
B. Fill in t h eI ~
1. The
2-
3. A
frrJU
~
21
loop is the simplest of all looping structures.
and ,~;A )Jp_ _.,..._~ are the two types of looping statements in Python.
loop i ~ d t er Ing over a sequence.
4. ------'-.,._J~--- is sequence, ·A'MIII~ square bracket.
5. ___.,._._""r-1~~"6,.,&,-l,_ loops will •hen there is a user-defined break applied to it.
' '
,
3. What are infinite loops?
•
_/__ /__
oole 8
a±/ l9'=
~
,
ue.,.t\ f
a
~,
{ ' ' I
► '
'·' $
(~
I
I
'
f
'
' ! ' \
I \ ! l I ' J
~--- ~~-- ,-r~ ..L.- ---:- -.l..- -~~~ --=- --r= -1~~ ~
~~~ ~_L ~_ ___:____,,'-•
~-~~~,J-W~~1___;,~i!.d....L
L!~~_M~~~~~r(l_JJ;L,__j_,' L--tal .
, f
' ' f
,,
' I I , I
I I
'
. ·.' J
I
I
.
•
~
·'
•I
I
I , •
<
; I
,/
'
r n
_;_ 1---
-
-