0% found this document useful (0 votes)
9 views

Computer _G8

It's my computer file do it for me so my teacher do not beat me accept it and oroceed to process God bless me Jqoahshsibsajhwheisiahsueuw Haisnsbsbsnsbdnansbsjsjsbdjsjsndndbdhdhdhsjs Bbbbbb ke baad

Uploaded by

t50325820
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Computer _G8

It's my computer file do it for me so my teacher do not beat me accept it and oroceed to process God bless me Jqoahshsibsajhwheisiahsueuw Haisnsbsbsnsbdnansbsjsjsbdjsjsndndbdhdhdhsjs Bbbbbb ke baad

Uploaded by

t50325820
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

e step-by-step given in Ex

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)

<< FLASHBACK >>


. gram to repeat.
e statem ent s are those which cause a part of a pro
❖ Iterativ
wh ile loop.
e sta tem en ts- for loop and
❖ There are two types of iterativ
g over a sequence.
+ A fo r loop is used for iteratin
en condition holds True.
program repeat until the giv
, +· The wh ile loop makes the
dition is met.
are tho se wh ich ma y last forever, un' til a given. con
: ❖ Infinite loops

A. Tick (✓) the correct answers.


ents in Python?
• 1. What are iterative statem
executed repeatedly
a part of the program to be
✓ Co mm ands tha t ma ke
conditions in a program
b. Commands that define
r to give inp ut
c.. Co.mmands that allow use
of the following wh ile
ue of 'i' is 1 an d it gets incremented by 1. Which
2. The starting val · a
use to repea t a task ten times?
conditions will you (i! =l 0)
c. wh ile
/ wh ile (i< ll)
a. ~h ile (i< l0)
ltipli~ation table of 17?
3• Which fo r statement will you use to pri nt the mu
a. fo r i in ran ge · (1, 10 , 17 )
)
b. for: i in ran ge (10 , 1, 17
71 ; 17 )
v fo r i in r·ange (1 7,1
-
4. . lte~ive ~tatements are also known as _ _ _ _ _ _ statements.
i f Looping b. Conditional c. Control
5• Which of th ese looping conditions will induce an inffnite loop? The starting value of i is O.
a. while (i>O) b. for i in range (1, i, 1.) 1/'hile (i==O)

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.

C. Write T for True and F for


1. for is a conditional stateme t.
fa1.)e.
,
.
. :
'TJ-w.L,
. 2. You can repeat a set of command~ infinitely in a program.
./
1j.u4__
3. A list c<?ntains ordered but interchangeable items.
4. You cannot use else statement in while loop. -faJ~<L
5. A tuple is defined within a square bracket. P-o.ltt1
D. Answer the following questions.

1. Differentiate between a list and a tuple.

' '

2. Differentiate between for loop and a while loop.

,
3. What are infinite loops?


_/__ /__
oole 8

a±/ l9'=
~

,
ue.,.t\ f
a
~,
{ ' ' I
► '
'·' $
(~

I
I
'
f
'

' ' '' I J I


l
t
t

' ! ' \

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---

-
-

You might also like