0% found this document useful (0 votes)
24 views19 pages

Python Looping Techniques Explained

The document discusses various types of loops in Python, including while loops and nested loops, with examples of their usage. It covers the syntax and structure of loops, including how to implement conditions and iterate over ranges. Additionally, it provides examples of practical applications, such as generating multiplication tables and checking for prime numbers.

Uploaded by

Ashray Dwivedi
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)
24 views19 pages

Python Looping Techniques Explained

The document discusses various types of loops in Python, including while loops and nested loops, with examples of their usage. It covers the syntax and structure of loops, including how to implement conditions and iterate over ranges. Additionally, it provides examples of practical applications, such as generating multiplication tables and checking for prime numbers.

Uploaded by

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

Loop Conbe statee

"Loops Used to peat he 'saoe ale


?ltiple tms.
.Python Pooviolos to tyes o loep se
-ments, viz ohil
okele
The

The cokele
fea
Conde

Lohile tet Gliten.


# lop body
stalorents)
test Falu
Toue

stop

(Flao chot o hile lap)

shile lap:
# nihalie the ane
# tet conit

( o tby!
# nçsya
1
poit(Sum

(R CHA SnAgrnA)
oohile

an

is = ", SUm)

En3: laAP to deplay the


deverse ot the

proint('Revoe ob d, is:", ev)

(RCHA 5HARA
humbers 20tht a
5 usrg while bop:

uhele

divisble by 5 s

a runber.

B) l p tot chek shethe the no

153|>15 153 |
todile
(RIHA StINRMA
The to lop

Lshich opeat or

dhe

eoch vale a

lata storol e
beey
-list
tupls.

auone

Vao takes a lonsecute vales , te

(Ricno Sn9Rma)
bop ae

pold (ve)

(,6):

pont (i)

Olp:
2
3

ngeles,4/):

The Capital letls


RICnA
Nc-Bo2/KNC- 4o2

The ) Funetion
angel
an hbilt tnchian wed
a

paaelrsRe
ingel) has , 2 oo 3
lat ttoo paaaes a phonal.

Gange ( stist , ond, step)

teging
ohick th list sot.
imil , e ast
he fey

» st (aingell6))
[I,2,3,4,51

(RCHA Sttaernfn)
> iet (rge (1, 20,2 )
L,3,5,1,4, !9, 13, 15, 1, 14]

oulut
lo,l,2, 34]
[i,2,3,41
[,3,5,1, 4]
Tange (50,-) Ls,4,3,2,1]
h3,2, ,o,|,2,3]
h-2,0, 2]
ange (o,i)
Snpty

(RICHA SHARH)
Pocqeano 3

foind 6awe ot Fiest 5

20 ehch ae
- Bble by z,3-oo 5.
&ors =o
paird I to 2o cehich
2,3 co 5 i )

5-0:
ut i ?. 2==0 oo f3:zD (
pint("")

SU)
pte
-tks eatot

triogua No
tetS, he
Coolol

JS

Fiost.o M(pd ("plz te Fiast No")

imt int (inpt(" Nos o Fitonacei Niomtes


Point: "))
")

Poid (Sorm, gd-"


Nested Locps :
Loeçs hin the loos cotn one
Comploley ckthi onothe
hen it is calleol heste lo.

duçlay waliplicakon
5.

poird ("mltpicaion Table oo

pont (omt (ij,'4A')

pojint ('Enol ot poago")


|b 5
2 5

4 2
8 12 20

20
(2 36
24
3
16 3 o
36

(RICHA SaRMA )
dispay the patz o seas

poirt("
poirdL)
paid ("enod o Poogan)

(RicHA
The boak statemat!
he keywd 'bopak elaos a proie
teomoate a Joop. he a tad.
satament is encoleoed inside a lo
teromintecl

Flao chat bk tulenat

(RCHA SHARMA
diaplay dhe patlron o rmbes
tollacs:
|2 3
12 3 u
| 2 3
|2

pYid ("Nomben Patezn iuplay)

por(

'poired i, anot)
pol rdc
((RICHA SHARA
test aean epreKston:

borak

btenets)
b

boenk

(RIcHA &nARMê)
Bxample :
Poime

the No "))

borak

) is Pime

not a poime")

SHAR) )
The conte stateet
Oppostle b 'bovak' stitot.
oithin
staleets the
chechel to see t the Joe shol

TRUE

Yes Coostinus?
No

Faactast o cotiee salet


obie -Joop:
lekile test -booeon - eypreko :

t (endiw
-Corbine

tor-lep
Bquine

Cortinee

cftatirendsy Catine

Boeck Cotne
&kips dhe cwent ie atien alo
bock or lop slis the oemaning

at the tgiming
Ghatimet he loot.
Nee minales the loo
(R ChA 8HRM))
Continue
point (i,endl:" )
Qlp:
2 3

Peoqpanol ; Read the oing "Hello Woo he


spae
Alsl : str Cinput l 'Plato Eites the
Boing : "))
pairt (" E t sing is :",aá I)
pelnt ( "Ater Rerocing spaes ;the stoing
cin l: becohes:)
i= =

Cootinue
poind (i, d=
please odis the stoia : tello woa

Helldeld

You might also like