j Tytron
» Tech foundations yen
‘
] thon
[eden | Peper | ed cata
|
1
Bosc TFeaminslogy why pytton? Axetherrate Opetatous
Gopcare - MH ISA Set q instuchens 0 the hondione »
Programing: yoring the Instuciens-
«Thee Wstucien® ase Cate] AS code
Rogrorrrg hanquage:: We Should que nstuctans 1 oO. dlorguage that computer und
«thea Marquages cre canted) Faoquomming lacquages
fF Syntor = Similan > Grammay wiles an English, Hind etc. Zach Prqrrnming Jong
' has a unique set q rules
f There wes Gre ona Ht AYyntax-
Why Python
= Versatile harquage -> Has appications In alrmst acy eid.
Wimos vestiet Goo Trade
«> (quae) > Gore Backend f
evctopmant /\pevelopment
heasning
Data Scientist
Plenty OP oppurtumties:. ML Engineer
Ryton Developer
Dota Analyst
Soren Deveteper
Depa Engnees-
k + Simple
Foy 40 lean pears
Seanned with CamScannerUsirg Pyttmn os a Catcutata:
© pantC2+5) oip- +
+ pantc"o+5')
Mdahtton : - Pant (245) ops 4
‘Subbochan:. print (2-5). ep -3
Yourypicaty: pint C54) — olp20
Division: pant 6/3) lp 2
Varobiee 3 atartypas:- I 4
te Spert : Cacket an
¥ oe «
vge.: 10 ee
ly cin Ye) ys Re é
oe Haight 43 \
“ (inf) i / 4
od ’ | ¢
pavcpoe byes ‘er { | f
> Vowicble ore tke Container fh SHowrg Values €
4q
Voriats te ed
= Values rn he Voniobles can charged} aa Fees per "
44 Brey Youur 16.0 type g, data + Stang 6
* Integer 6
Giang) Stieom q) choow enced on 2 FO
: Quotes. oe 8
Si“ Opicket’” ae a 6
+ Copia Letters CAtme) rat e474
; ae ae ae Hetio, wortd! ” §
+ Spear Chooses Coie $7.49) spaco ¢
cian "Book" — dane @enmpe: at
Drteger:- An number Cpositves negate’) oirout "toa" “seghezhete done
“Bread,
ny facneras past ae:
s6 232% 1,2,3,..
fotrerrancal Volue 2 Character
SDAA ALM
2 —> integer
Yo" — stung
a 0 = feat
Scanned with CamScannerPVUNVVUVYUVUVYUYWMTUYVUMTwT UHV UeYveevrwe rrr
float. ny number wih a. Charro! point
pfoctiros Part
Also
94-2, 3N5- 20, 321-86 i
Decirrot
Bootean:- fata that hos one g, “tuo pessiblevorug Point
Yatues that ore ethor
+ True [false “Fase” —» Bostean
pala . ”
: Tle 5 Sun
+ off
on B OFF ete. -
you
Vissignnng Yatue to 9 Vawalte ;
Yearning an intege value 19 to 0 Yavable age aa
Koj Takeo p= mT cS La a
9 on Datatype Dgniton “Additional Examples
+ Voaobies Stace 9 chovatier? (WARWG| Ban"
: oss St017q | cpa ruven t Robe
at | Adnteger |... -3-2,-1,0,1,2,3.-- 10,1244, 3933, 12130210 ete
2 Ploat Float Numbes rath adectmnipeint — | Qy.3,34B.O, -BaKes, ae
ae Bacon | ipa Fate ope | Tae, Fatee i
+ Vicagning Yalu 40 Vavabie
« vesignment Opmraton
Pr forraes sequence Cline -by -Wine
aD i
=I Sequer of Tron ucror VA program 6. Sequence g inshuctire $0 Computer
apne a Vatable +,
Pinting Yalue I Cr Yowiable: .
Commnen nistakes A Exot: - jy hoe oi
pant Cage)
olp.- 10.
VA Vowabie gets created wher You
22217 a valUenb it 42 the fst Hme-
age
onder ¢ erm
) age FeanECose)
pare’) eel
op Oe lp nao
Seanned with CamScanner
|
|w Spaarg in_pytien
Howry 9poces oF the
bgerrg 4, te caer
aliases
Cvaluel none
Value in Yorabte !
Jas > fi
%)
oD)
age =10
“ part Cage)
op: Eror
4
ft ped In
Sa 1
)) paintcad
Sage > Gl
pant cb)
Wael > fiat \areign arn
asd :
panta)
Paintcay, eer
bo el ;
esa ol fa C bersaivalve®
pantco) BE Sos 2
pantcb) >
ma
asl
bea.
baa
paintca)
pont Cb)
Ca 7
be> z =
S osbry =
PantCa) we
Paint Cb)
dpe
1 1
2) a
ae)
b-a
b-at) ©
penecaye
Point),
op:
O22
Puintcay ©
o-8t)
Peintca)
~ Scanned with (amScanner
Apt a
3
SLEIPAEPERPERRRARANADAAANARRD DDO DODD:Exxpressions_in_Pymon'- Express? isa valid > atb
a = combat G lus yg ato
yawabler £ operators: > #2434
fe Q= [243
b = [34 2) bExpeession
Cie lab} op: 5
pantca) i
pant)
Pant Cc)
(OstergobaGpachons 2 5x 1+ 3K
What are the dyjerort possible ways to evalucte “Hk expression?
BaD + 344 Bart 2#4
pore oe pete + ppcadha
Yo + 12
Boies Ce
Balt 34
LJ Appenth -3
5ea+ R
be lb a)
Qs thee ary starcad Sder forme
BVO Dna “Awe
906066
Bracke onde py,
in Muah Adiitin Sublracea
tee! Bop mas
22
Use braces “5 better
‘Seacobilthy
CP49) + Gad)
Scanned with CamScanner6 pant Clol +3
olp:- 8:0
ny pameC to / C24 3)) ,
ap-a-0 | § Ma
@ Akey Takeaways
© Vosiebles
© painting assigning
@ Cornmen mistakes
ra peo
© Expressent
* BopMAS
|= Snput ard Gulu Basics:
‘StmirgConcotenstion pantca)
csturgs stig @40be) Tao ig
Vidairg Sturn: y mo | vceing stung: 12 called StaingCancaterat
Pon carta
9) Jas"Heics” "oad
pentca)
O1P Hello Word
i) | Usenosre » "Rove!
Pant C "Hi" Username)
ip Ht Raw
® Ta="* ho
PantCa)
DW Lae eH gh
ke Pic
a RR RAMA MDHMAMMAMDAMHA DDD AAAADAAA A
> Op! Type Ewer:
Caney concatenate ov
Crot "int! to stv
OY te ae
Scanned with (amScannerTTolerg Thput fom Uses — input )
what HeWant fo pHNe 'O- aslersks 2
Gh above sas pant 3 ohare Castres) but ¥ fies
meng Repsoner Pas¥a to > akong va be Bepsotcel JA 10 tenet
PRntCo) | olp. e wae roe
wh [a pep 10) ofp: pmyapaye pmpnya--- lo hme
paintca)
ws. "Python Sill ais 1
32("s "eg a)es+C'+ #3)
panics)
op. ee Rythn *¥*
he ce Sto = ec
ee useename = “Ravi 25.5 ¥
= lengis= tenCusername) | praca. aguen sting
mage Gian]
—» username =inputC )
Willows Ftexabilriy to take the input fron the User:
Reads a line > Mput asa sting.
inp Alay
tergph ~ len Cusemarne ) oe A
Pont C Length)
®% [Usemame xinpute) — a es
age = Inpate > 2
Pint Cusermome 4 ig" a
. + WS Old
Ce ee ON as is
feessrg chmastes in stare a
we can ames IMdividuat character
1 SRI athe Wwername —_Usarrame [0°]
C&thich otans fren 0) Ravi! * Rt
elas
“These posticns are alto calle}
os Index
Scanned with CamScanner
|
|Usesmorne
© ’ [ User name = “Ravi' si ‘i ;
| Frat letter = userramel oJ Ravi,
| pant C-Aist_tetter) ap-R ‘
(ee ‘
& | Useerarne = "Ravi" t
PaNt Cuseromelo) > opr R veenerie ‘
| pant C useinome (19) $ * Ravi ,
| pant C Usewname (2) ) | i Gino!
Pant Cusewamel 3J) ¢
r ‘
® | uscarame="Rawi” ‘
} of eet cn Useerame
| pant Cusemame4I) | ea
| | tng idan at G ¥onge Row! «
«
® Hey Tokeacoap- he
+ Steings é
« Stsing Concotenaiticy é
+ ston Repetitian ,
pa erga
+ Trees
‘a §
=> Tepe Conversions ;
1 Pont 4 : §
= Tet q ._SbiNg: Obtaining a port q& sting 18 cared Stang Shr =
- Hi Rowi"
6
4
~
«
*
mess09¢ re Sep of grees re included) .
c A messmyel 3:6 «
A ea ——- “Ray” A
erdiinder 6 not inenided: S
3
8
5
Scanned with CamScannerae pant Cpart )
3) 2 ) message -"Hi Ran"
Paes Jinesone (BET ae Rat
Pant C part)
1) message ="Hi Ravi"
port = message (3 J Hi Rav
pant port? se _
p- Ravi
4 Gb message =" Ravi" Ds gy eret index 4 nek Bpeayech shown. stot at re
SPS port ~ressage(3: J) | end g me sbing
? pant cport)
ap- Ravi
8 message: “Hi Rov”). ay stent_index 18 not apscipied, cheng stents fom
Qo post message C 12] the O index -
Op Ai ener included
3) message -"Hy Ran” 4} start and end ndex are not Spec'ed the
Pop parts masage 0% Jy sted sting 5 Sono at te Orginal sting
ee part Cpovt)
pi Hi Ravi
W Messoge= "Hy Roy”
Stat_inder 3 ate
end. ircex= 4
part < meseage (start_tndex :end_ index’)
ppxnt Cport)
“Type Conversion
“Teo Numbers !— .
Acting “eo Numbeii= het ug uowilaah Preqam to fake too pumbow op
IMP fom the ger
Numbers +
On park the Summ g_ trose
Scanned with CamScanner@ Ot As inputc? silane E Are values in variable
be Ee 4 outpet’ 93, aad b stars?
result = a+b L
Print Cresuit)
Vowabie & Value 5
Check Rata“Type!- cadet pant (type C10)
iss wee aire aly P
poseoceates ap £class ‘int’ >
{Panting Date’ Type:-» PArtCtypeC 4.2) 9 Klass “Peat >
» Pant Ctype C'Hi")) ofp.
¥ A Fate
PintC-typecay’) olp:- oS
Chonge Data Types. Tipe Conversion.
Dyer the value q ane stting <> Integer
cbtatype -to arvirer clata type: Integer <> Fleat
2109 40 Trteger
—» IMC) Convert Vavel clata oF
OMY pe tw Irvteger:
4P*-
s
O- “Five”
iP! Value for: CH fie a iyi
o-kCa) Imatd (eral! te Hee'5
paint C4ype cay) base 10: fie! be
"Gr" 5ig
th eRe 5 Value Pron
Pant type cad’) ink Wee vp,
k bose 10. "5.4!
Scanned with CamScanner
RRAPPPPPPPLPDADAAAAMaaaa~~ ~ -0) code:-p/a-InputC) | Dnput
= Intca) 2
be input) |
[Sentrt Chunar poten diggs
vesurt-atb | 5
Leos)
= InputC )
a=intCa)
b= inpurc)
b- int Cb)
west = ath
output: Ty peError
Con only concatenate str (net ‘int” to
i SttCreoand}|
Pant C"8ur: "4 resut)
X
Olp'- Sum 3000
lype Conversions;
inEC)—> Converts 4p
ye MMPS
si toat datatype
SC) —> Sting chtatypo
bool > —> beolaan chtatype
= Chast 4 itrng te sean)
ona eke
* Igpe Conversions
?
?
?
?
?
?
?
> + hype) (a vatialdyalie chletjpe telus hud
> . Sb + rege
?
?
a
?
?
?
2
“integer to aheg® felational Qporator :- > is qreterton|
> Used +o we Valuer Z L515 less than
> Ges Ture & falye as the Tour q, Cernpawscn:
te pont (5 410) , pant C5 710) | part 1045) t
Fue sr-false or false «
‘
| «
,== => 6B qquol to
4
| te —> 18 Not equa to ,
|
| re > 1s greater tan 8) equal to f
eae —> 6 lessitan & equol to .
| Si) «
Composing. nie «
th) POR CAL=Q) op. Tue ) pant (lO = =10) olpstue wpank 5 )=1o)4
dh port C4121) olp- True wy Pant Clog = 10) op Tue Tam
Common «
mestakes:) purst C3 = 3). ep: aoerar. ‘ ee,
Pant C2==3) op ie
9 PPECD & = 3) ofp. invatd syntax =>} pace betasy Ylansra| |
Pant C2.c¢= 3) ape Tue operators ==, >=,2>,J2| &
1S not abd IN pamn |
|
| Gonpaning Fonts.) pant C95 22 30) apr Tue a,
pent Cot |= 0.1) dp False ‘
iy Point CQ.63 4. 2.55) ap True :
Sanpeeey Stars) aint C“ABe = = “ABC") opt “Taus |
@) PANE C’CBATI= "ABC" op-pare ;
DE Cees)! ae. Gyee /
w pont Cape” B) P--Tue |
‘
wypant C"ABC” = = abe”) defaige
5 i ‘
Pyren is Se Sepsieve ;
B rnmre RK ang a on
rot Same I) pansn, ;
Scanned with CamScanner< i a P
? Quester. loete a. pogrom 10 check te hot “hee chenactert gy tus
Stings aro Some” Srputi- Apple |
yt oy Application 7
SEF Breet cult: Tus |
first ine 11 niin ashing: ‘SThput :- Banana,
Securd Ine 10m Conain & sting. Output: me
Cupar. fora :
Pant “Tue 1 re fist three Characlets | ina
Y) both 4h Strnge Ore Some |
tp Tue
Pant Halke 4 thay are rot equal L a
inst_sting = input)
Secrd_ ong input C9
Arot_stang (0.3) 4 A
scard sorq (0:3) _» Ay
frst_storg part = fret sting [0 3)
Sexrd_Stirg. port = Seon sting [0: 3’)
CArst ,tnn
prt
eae Chee sory lpat = aera sng pt)
pant Ceesuit) tS
olp.- Tsue
=
ee tay
2 Relatoral Operators Banana falze
(7:42 =)brbeyeed
+ Campoung ahinry
+ Equatlyin, oe
i = BooleanValues-
jem logical Operations 7» EeoleanValuee
eh — and
3 -C the Yesult
Gives “Tare & False ow the Yesul age
5
not
and _Oporatos :- Gives Tue 4 both he beolears are Tous ee
Bise, it ques False | A Band
Taue True “True
Tuc Fate false | A od B
fale Tue False
Fatse Fake False
& pont (Tue and hue) +" Tue
pont C Truc and False’) False
Paint ine 3) ard (1421) Tue
Pant ((243) ard (2<1)) Fate
pant (C5 =-5) ond C3¢2))) False
a _Cpeator :- Gives Tue Ip pare q -he booleons cve Tye
—<——-
Else, % qwes False NS wane |
t point C Tuc 0 Fake) Tue ue Tue Tae
pant C Fae & faite) Fare ruc Fale “Tye | AP
3) False “Tue Tae
rapes eae 21 C341)) True eee ne
Pont CC3<2) & 21) Fae IpSeceln Se absi.
PC Cac Cac) True
Port CC2¢99 a =i) Toue
‘u :
Mol Operator :- Giese oppasite Value
te point Crot (-fatte)’) True
Pare Coben) Rua
Pare Crk (223)) Fate
pant (not (l=) Fras!”
r
Perk C4465) ond CrotCHt=1D)) 5,
T
an NOLCR)
7 od = T
Scanned with CamScanner
and > ques doue } au
me tre
od > We tae
4 tetas YEE
TS 8 me peea a
G a
y
Queshon:. vowte a psogyomn ‘check
ae
ortteact cre q the numbers }¢ greater
€
4
ih both tbe numbas are. pasiive, ond iP
hput format _
Fist We g -the wnput Coll be a positive Cee
& hegnive number 7
—
Gecond bre q. the wpa wilt be @ pose cs =a
2 naive urbe: | a
Chae |
qutput format: - ——
ul that =
paint Tue jp hoib nursbas are pasitve pes |
ond iy GHteast me G the umber ig ee
Greater than Ds [e.o|
Gp # 18 Mot, pant Falre 1 as
eens
[|
Code:- Fast _number — Input C) ,
first number = int (-that_number’)
excord_nurcber = input)
second murmber nt Caecend_numbe)
is -poottive = (Grot_number > 6) ard (Gaara ruber > 0)
B quatershan = (frat pumber > 5)) oC cccond! numba 75)
zesuit = (io postive) and (¥ greater than’)
pant Ceesutt)
Hayate
ool eae
oo
one
+ Code otttincerf,
RENEE F800 OOS LOY TW) w=
Scanned with (amScanner® A ‘nditienal Statmerls
Fallows ypu 1 execute O block q code ony Khan a Sproye
Condition 8 “hue:
‘ig’ canditional Statemant :- Selectively exccute a biech o code.
conditional Statemen
pan ov falte Cexpcosin hot vauts 9 centres)
Sage
to dnt
Corcttenal Block Excutes only Hf Condixn 5 tue
7 — Standard psackee 1S 4 USe Foun Spaces cfor indentation
Ex = Int Cinpuec >)
rl
Pa eee) Snpat:
fase Shan Rewe output: 3
eee
paint Cos.)
]
wo = int Cinpute ) | mma: 2
| coms bsCipetC Dc pinoy vee 1
| 3
iz br tee }
[nlf Gu>, bom i
—— peintCa-b) es
part Ca+b)
Poseibie mistakes i
ob if Tee:
point CSF Block”)
t pert C tree ae) x
pont ‘Grade OF) A
_ Sut Ordantaten Bowen:
Unexpected! Indent
4
= Foch Aaternertt 1nerde- cerciehona! biock Should have came Fnderdatin Cepacing)
Scanned with (amScanner
PL PPPHDDHHPAALLPHDHAAMHDAANADAAMAHA AMANDA NaA «a a «zrc _ 2
@) wy Tae Int Crete) 2
- A é Output
ip ato. ees in
a=a#c-!) s
paint Ca) x
PontCarv 4"
Ex:-i, i Toue:
Ce ‘ > Condi
Part Ccondhitora! Lock) xe a Ae ae
Paint C’éry")
Ww # aya: el,
Pent Comctanat tock!) 53a!
PortCerd’)
Question +. wmte a code 42 pont “Positive if che input tc Positive
INot Positve’ te "Put 16 not postive.
ae) la ~ Int Cinpuec >)
JiR ay oO:
Scanned with (amScannerScanned with CamScanner-- see ee ee ee er eee eee ee
False ;
paint Brock’)
Common rrvstakel-/ if
port Caeter %F")
else bik «| else!
PantC’Else Block")
poineC "After Eise")
if Fowwe: -
| Point CSP Block”)
| pant C'Atter 2°")
| ase: Ye
paint “Bise Bleck")
a
point De Back’ >»
paint C “Apter a)
ace: \
Paint "Ese Bleck”)
pant" erd")
ard etse statement:
Note: No code 18 atocwed in between Hf conditizal block
hea Oe rec rneter a ee
"Heo" -eronaed —_
Cousect V
Cee Oe rp lange: wort
Part C"Hetio “ya Joma Hero wor
Vv
OkeyTakcaxsays:.
+ Conditicns
© GF Staternent
+ Grdertoney
© POSEIC ter Stakes
© GF. Elce
+ Carle wancthecigh
— Droowrect KX
= "Raby"
[PAPECHetio" +a.)
wie: Syntax Enor
invalid syntox
autpyt:. Else Block
After Lice
DF Block
After DP
End
cut:
Input Ord pont she greeting
np: Rahul
Ourput: Hello Rahuy
Srput : oid
eutput: Hetle Rahul
Scanned with CamScanner® pretium doling ee
1 ber
@4: Uhite a pogram to pint the greater} arrong tthe too ae :
format : 4
Anput format! - 4
first bine will Corian a Nurnber- pets a
Second line will Contain a Purnber 4
utp
Qutput foamat:-
Paint the greatert number amang -two number npet-
9
t= ouput:
Cexing, Approach :
first_ number = int Cinputc) )
Stoard_rurnber = int Cinput ).)
pont C frtt_number) >) :
pot Ceecrd rember) | PCPRE Wheiner our code" coneat fret
i5_fivst_qreater — C-fist_number 5 geeeret -nuertor)
part Cid Frit Qvdater )
iP is first_queater ; rue, Falke
pairt CFirst_ ratte
else
Part Secand, '‘humber)
Scanned with (amScanneruv
Coding - peaches Qa CMashing )
LRRBVBRELELELULVGEVVGGVGHVGHTUVHTHYY
Qa: lAbite a Pym treet yeads A singte tine input and” ports the
®
a
Psy and. last characters of the Qyven Input and pants the Qstensk
Trput:
Chonacter C#) In place 4 wemaining Characters passcoodd
o f output; ~
Mhpat fornnat peeexxd
frst line wilt Comain a Stein: Dp:-
Python
4 Ips-
Output foamat nu par
nt
pant a Mew Wd WHh aN asterisk Dp:
Chonacters CD between -first And. last charader Psograrnming
Wad WW. Olp.-
oe Pe RR ER
Code
Weed = Input C y
Woed_length = Jen Cwoid)
Rost _chavacter = Woxd C07] H Hello
last _Chawactes = wood [Wwoddlengt -1] 0
Hows =k" (Wood _tengtb ~2) nee
sesult = :
“frst choroctes + Stavs + fast character ofp- Hae #0
paint Céesutt’) oes 50
Werte ao a
a ahs Check i te WEN 4420 ligt Pureber B Queater thar 2
aon Beate tron te sean ‘|
Ging forest dgted ge
The -f ‘
1S Noe G the Input wit ke a 40 i, >
cuiput orrot TE Fee reget aap1 Comparing
digits
Coding practice
Paint Toue
Gy the: nurcher ig greater than 25 and i -fist Clight If gscotey thay
ita Gecord digit
Snput
Paint Falee a4
Gh an Other Cases output
False
Code:
~ Number= intCinputc ))
S_nurnber_ greaterthan.25 = (number > 25)
Nurrber _ sta. = steCnurnber) we have 1 coryert ts
We cannot acca frst, lost
frst ~Argit = Int Chumber_ sts (oJ) — again for oun 7
Second digit = int Cnumber_ sty cd)
iS. first_digit_ greater = Cfisst_digit > Second oigit.)
Zesutt = (is _nunnber_ gacater than 85 ane is frst digt_quatr)
paint Czesutt)
eArithumatic APuratas:-
‘Remainder :- To “ind the wemindey, We Use Madulus Operator (% )
eer PICA 4) opt as ;
im CE % 3
Paint C@,2) op. 0 Fei
0
Q 1. Witte O Proqeam thor determines Hy the nen rurnber wv
res Peer es
: 4
Gnpst foroat output.
Even
Firat ire way Contain a postive imager. Ghput
5
outpul foxrrat’ i a
Int Ever the hoe odd
ps % PAraBee |S aN evn Number anput
Pome eat “te renter fl Gn Gad imine
ouctput
Ever
sting dedatype C
choracters.. .-fron int
eguirement cawerted +
LELLELRPEPPPPPrprr PPRPpnrnananmn m= sr ke¥ =e = STS TTrTrWTreVTrTwrweartlh eG OZ
"re
Number = Int C inpatC »)
Bernarraby = Cnember % 2)
1S_even = Crarainder == =O)
If iS_even +
pairrtC"Even )
else < .
paint Codd’)
Exponent Te calculate the pocver b we use Exponent Opssatd: Cex)
Qii-
b code!-y Qaex it
(ee Ak ARIK Ag)
OLS eee
b tires
) pontCa #* 3) —5 2x24 2
ap'- 8
10000
a) point (lok 4) —> l0k \O # low (0
Given +o Integers at and bf! te greater orrong aia pray 6)
2 nl q 2
ard b* Cb peces a) and pant -the Value: Onpst:- > os :
npr format geet q
3 3
The fist line q Input Is an Integer G ae a
sreteeae cigar! = Eade Oo 8
output for mat
Pat the grecttast Value amang a b Ca power b) and spe Oi
D)- 2
5
code'-
Q. = Ink Cinput 7) phe Oriel
b= Int Cinputc )) ee a Seeot ee
; on 4
Q_pootes_b - bpower_a
iP 19_queater ;
point CO_pecser_b)
ee olp'- 9
paint C b_pocacs_a)
-
-
\
sj
t
j
iRASTENS IOS Ordre Murnper point Lucky Naurmber y ONG |e
Conattions axe CohSfied 1
>The number 1S A Multiple qd q-
> Me G the digits 's 4
pant “untucky Number” In all otker Caneg.
Qnput torrnat
The frst line 4 input Comians a “two digi nurmber
Outpat Aownert
A} ME q the chgits 1S q «Sy -he Humber 1S a muttipeg 4,
pernt Lucky Number @:- 14
GN aN orrer Carer point Unlucky Number O:- Lucky Number
Code:
Durnber = intCinputc >)
1S_Thurtple_oj Ve (Gurrbce % ge 20)> nurrberogren dide ese serroirder==o
ourte tue! avtundi , Leconte faite vastund:
saa pn oneensvnrpnepaanaaeshTfr id
Tumber_ots= sta Cnurber) ithe @ shiny ih corave chia brit digit techutotoniti/atioG
Fret digit =irt(Dumber_ atx[o] ) <> Vachine choracter9 inl la Covet chem
Seo digit = int Crurber_ateC i) .
Is_first_digtt_q — Ffrst_dige i) = fut digit % ahkeada on check Cherhenam
iS_Seard digit_ 9 =’ Gard_digt 3) 1H ety ’
1S_any _digit_Q = 18 firok_dicnt_q 3
1S_Seaend digitiq |
condition - :
= {2 _muttiple OP_q og 1S any _dignt i
HP condition :
paint C"Lucky Number").
else |
paint C untucky Nurbay"’)
@ - key Takeaway! a
Le
+ Aiitipematic Cperatty
0 MoChitess (Gy eS Oo Purber ni inko qumber Bs “ah cheniroppede sdercaindor (stands i
» Exponent C4»)
¢ — Pacblerm sowing 2 Delraging
Code WAletnrush
oo © a2. @: Or OrQ Gen N number g clays ag input, rite A Program tp Convert |
N. nurnber days to years Cy), weeks C WwW) and clays CD)
Take | year = 3EH Clays.
Nete |
Or put The input Corrtains single Integer Ne
jutputi- Paté In each new line Y, LI ard D-
Given N=13aq- “the talue can be Wootton as
Peeplanaha:
1329 = Byeart + 33 Weeks + 3 cays
60 the Ouput should be
ee
33
3
Approach :-
step | Reodt abe inpur and Store In a Vawabie: let Ht be murnclory=int(inpstc)
stepo: “TO get the number Gg Yyeart , duce nur_chy: with 365, because
Ch year E 365 chy) 4 Convert Ht Ko integer
7% Year’ = int Crury clays [365
Step 3: Naw, ‘get the temaining Clay to Calculate: 4 weeks 4 aes
7 tamdayw = rum days — Cyeau) # 365
Stp4i- TO iA the Mumber gq weeks, Clucle dem _clays wrth *f, bacacwe
(11 Week = + days >) 4 Convert 40 In
—7 Weeks = irct C vem, days aN |
step 5. Now find “the ernaining cys +o catcutate “We cla a8 betoco 4 “the
wernaning day wit become chap.
2 chit = 6r7_clays —C wees’) ® +
Shp 6'- Port om Years, Keekg and layp icine euMgrs Conditional Statements
=> HP _cordition A:
Block |
if conditicn B:
! Bink 2 —
Block 3
Block 4
if Condition A:
Bioch! O ;
Biocks O)d
? Toue
> Taue
Conditional Blocs G
, Nested Condittonal Block 5
Conitinal bleck inside another iffelse 5
Condit’ beck called Nested Conditeras
beck. €
G
¢
Grditan_a =Ttue ¢
Coraition_ b - “Tuue |
© cerpitcn_a: 7 c
PainkC'Back 1")
+P conetrtian_b: ‘ ¢
Pant C'Bteck 2°), ced
petChiend de “Bake
Pont’ Bia 4”). / Biot 3
Bick 4 |
. 1
comBHiM_A =Tsue
corditin_b = Falke
ie CodHig_as ,
Point C’Biock 1”)
fF Corditicn_b
PaintC"Bcck 2")
PBMC Bleck 3") Op:
+ PBINEC’ Breck 4”) Biock
Block 2
Bier 4
Grdtinn A oe (Bers
Cord b _ “Bye
Ve corditin a:
Faint C'Biectc 1")
¥ Conctstian b+
PSINEC’ Biock2") 2p -
Pant ‘Bioce3") Bloor 4
print C' Blosa”)> if condition At —> fale
[Bock x) |
b '
' iP conditiay BL — y false
- 1
SL Bleck am)
; erleees 2
, | Block 4 ; ov)
r Nested Condition in Elée block i
r ip condition vA
, \ \ 1 Bio |
> etae + ( hoyit
y ia" 1a | tO pe , “
vi, if rete | WE can alto Write Nested corditions
y \ \ | Block 2 ! ;
bi ea brie Cait Siete eile
» Pe Bows "4 qd ) g 1 2
y Bock 4 + Ferahox op Oo al 2
> “= ai 7 OD) sry
a fy an) : 19
> ()) Gonditsa_o. = Toue Pp cle Cenditian O. yee Cerdttin a. = Fatte
Ue
Goria _b = Fale ; 5 eae pt “condition. = Fane
; afrst We tom aaniain Imeger
Seand line vat Contain Integer
Third tine wr Comain integer
Outtpurt ‘foamat :
Paint -the Greater nurebes arrong thee inputs.
QO = int Cinpatc >)
b - int Grptcy)
C = int Cinputc >)+ i Cardtin_a = fue
Caditin b == Tue
if cenaitin_a:
Pant C “Brock #’)
Cli Condition. b+
Paint C"Biock 2")
elSe :
point C"Block 3.)
Cutput- Block |
y
Block | x
CHF canditim =B:——> false
Bicck 2X
else +
Block +\
Muttple Eur Statement
iP Corditiay =A:
Block |
elif condition B:
Block 2
elif cenditiay c!
Block 3
aise :
Block +
Cpttonal ise biock:
if condrhay A!
Block |
eliP Qonditiay Be
Block 9,
Clif = Coditia ct
conditiay A :—-» falce
condttiana = Tue
anditin_b = Fake
candrt1a
output:- Block |
Cannot Wate an elif blacks
after eise block
vae can ade any number of
\ Cl blocks after if block.
else block 1 not Compultou ener,
CLP blocicgKeops:
> Allows to execute a block 4, Cade Zaverathnes:
while loop
— @ python there are ~teo Primary ways ~br loopy] tty leop
While hoop. Used 4 excite a block g code several Ha or long a»
the condi is Tous.
jboAIle Corctrticn 3
Ex: Lets pote a Code -ip Punt the
nett 3 Conseaive Numbers Fits
gwen Integer Inpeet- Gps Tryout
| 10
cede) = INEC Ipertc ) ) etpu auetput
a= adsl A "
3 a
PpsintCa) | 4 te
Q= An fatic3 ‘How tp repeat
prntCa) ttese by using
. ¢
a=zat &4 hoops.
Psintca) Tnttead a Writing 3 tres.
© Q= intCinpurc))
=~) While Condition :
Q=Q+!
\- = = Paint Ca)
Le& initabee a Counters Variable to
check 4 the logo hen executed 3 times,
Ww) Q = In*Cimput)
leourrter =O
--» while Condita +
a= atl
]
| => Shrtahraton
hhh n mh Mm
fh fma= intCinpet ©) )
Counter = 0
while Condition :
: a= atl
point Ca)
Countey = Counter + '! —+ Updatian
pant C'Erd")
Q = int Cinputt ))
Courter = O
» While Courter £ 3) : —» Tesmination
Condition
Os=. Cb!
Pint Ca.)
\. 22 - Counter = Coumtes + |
point C'Prdl”)
a Q = Int CinputC) ) , |
| Courter =0 “|— Thitiahzation |
| > While camer < 3;_, Tesminatian
|
; a= at! SESS
| \ Point Ca)
| | = : :
hss 4 Counter = Counter + || —-yUpdlation |
| part Cena") ;
|
iT et
x f
g Drbaliaatian |Excecuctin q white loop
Q = int Cinputc >) ~~ :
Counter - O
>» While Counter <3: T.
a a=a+l }
paint Ca)
— — -\Cournter - Counter+ | [i
paint C "End" )
Common mistakes
wo as intC impute ))
Counte1 O | ee
while Counter 4 5: | ot
a=at+t ( wen
Psntca) ’ Snput
Courter = Counter+ |
Fe ene Name Exon:
5
Mare ‘Counter’ is mot
= Q = Int Onputc)) nine :
Core) : ee
| Cordirticn ~ Counter « in Ss
rh While block Wil) keep
ihe condittan | Sepeatirg ot the
a-ad) Value Ip” Condinan
Point Cor) Buable it Faye,
Counter = Courmer + |
eo Q = intCimpute ))
canes =e (> OY eer 8D
while Courter < 340 4 v Gre AO
Pe 43V ae an
print Ca) ; a
Countet = Counes ++ | 3
meow Clea") nd
PERE LPELEPPPPPIPPPPPPPMLPPAMMPOPO LP K ELLEé, a int CinputC) )
Counter = 0 | not -
while counter < 3%
a=sa+tl
paint Ca)
paint C"érd")
Q: Squase Pattesn
wsrte Q parr tO pant Sax IN N reds ANd N Columns, Where
integer Np Quen OF an npr: prt ;
, i, 4 x * K *
Tn eTTDE
Dhput fourent * ee F
it | u |
Fist ime will Comain a pesrtive ye a ted
Quiput format free : st :
part Stars In N Xo and N Colunng. : :
5 OK OF de
Note * “There 18 a space after rey. if Nononege
e ; OE HE FRE ok
oadle N= ineCinputc)) > eee Ete
Counter=0 -1 se
while Counter < Bi —3
pont ("# "%1n)
Countet’ = Courter + | -2
for hoop:-
« v Lap
eee
Python ce th nes it 3
i i in '
ae ee --
A stang
ang Ba "
Ardivicsat chosacters
Sequence of Character,
A block Cade ahoutd be
executed ox ead) character OF Sting.=r es staternert Wesates Over Coch ltern q a Sequence
© Sequence q chenaders Cstnng’)
> for each Hern IN Sequence:
° Saquence % Humbe ete.
Et yom =“ Python’ 3
= Fos each.chas in wodd, \ dnitialiaaticr
I erni mation condi
\ccae pant Coach chav) Minmatncendi
ho
Execution Step-by-step: Ceequence of chawacters”)
wood = ‘python Cutpute
p
ry foo @chchas in wood: - y
Moss point C cach chav) +
Y h
P ut t of °
n
Sequence of Numbers 1-
Hod 40 generate a Bequence g Durpbers ?
for each number in Sequence q munbers:
ec 1 [Pepsarntiog cae
tonge Ch)
v
SAPS heme n Preise Oe uanne
Cn 1S rot tretudad’)
ees) eae ale ilign laced
Goes Sequence q aa, a B elLTE "e"e"o oe envdTIvwvvvvwvvvvvryvr YY
e Or Purnber in ange C3): output
paint Cnurnber ) o
2
< input + 3
hy Ne intCinput ©?) “Output
0
fox numbes In zangeCn) | |
2.
point Cnurnber)
Q@- Right Angle Tatangular Pattern
oY ypu
waite a parm to pant sight angle 4
eget pattern, Where Integer N Output
1S Qiva as input: *
a * *
hp forrnat, eX
first line will Contain & positive integer. eK RK
Output format Dit
5
Pant Bight Angle -biangulay pattern Cutput
Note:-Tthere if a face aftr every # bs
* +
Code x * OF
1M = IN-CIMputc DD
“fos Mumba in Sorgecn) :
pant” # Churnter+1) )
— n= mtCinpte))
Rox Counter in wanqecn): Thstead gq Starting -forn O,
pant C # ® 6 Coounter +1)) Con we Specify Start inckoc of
targe -ancian .
generoes 0 Sequace Numbewt
storhng fom this. 4
SHOPS beyme end
Cend & Mot Ieluded )ange (5,10) —> 6 ft}
Bight Angled Trrangle Patten
n= int Cinputc))
efor counter in. tonge ChnH):
port # "x counter)
Fossibe Mistakes :-
by n= wrt Cinputc) )
for Counter 1 Barge C1): ~
paint C "4" ge Counter)
OQ) ckey Takeaways:
+ Sequence
+ For loop
° Hevating Over Q Sequence
+ Rarge
* Sequence OP Nurnberg
* Code walkthrough
+ Possible tistaker.
D
tal
& #| Diving !Dethers
Secret_mesax
> GAA we extad the pore “Ravi’ -fan this sting? qe
Rio) yi
> 1 extact nome for -this sting, We Need atteinate
Chonoces -fern Index |.
y
' \oaable [Start_incbs: s end _index : atep]| O'! in 345646
3 ; *, Ci:8:2)
) F-1008 = ~—R-a-v-j- gp.- Ravi
, pont Coad [1.8:2)) Sectet_ message [1:8:2)
; ce e
& qe “waterfall” Ea
’ et afl-6:3) os om Base te
’ watelsifaw) LY ey" Poa
, o\ tela iy |5 6 3k
‘ 1 e
’ } ”
' ~ word - “waterfall OP ox
port = word( 11613)
pant Cpart )
> wod- “waterfall”
op aefl
port = word (8:2)
pantC port)
Btoing Mathes 7 Pytron hos a sot op buitt-In reusable utittics.
> Thay 2impity tbe moet Comrronty Pere ened operation:
+ isdigitC ) + StaipC >
+ LlocserC ) + Upperc >
« Stoatswith C > + e@ndswkhC )
° ceptace C »
(www vv ewweuvwvevvwv wwwRann one nnener case conrenrrcznesnerennznnnennnneeneeenennnnes qemmmmserrennenens ons rrm oo
lets Say,
You want to set o 4-digt PIO We Need to check } the pin
entered by Q user iS valid:
oceess ty
= Cheech each chaxader Gp “he Input 16. Nurnber
—s check y the lengib Ghthe input 13 4 digits
Stwng meitod isdigit C > arrpitfes Ws:
isdigitc) -
- 4748”
Sts_Vas + iscigrc ) pin- 4448
i ae . isdignt C
Gives Tue all Character § are digits isciqt = POISED
iS_4 digit = (lencpind= =)
iS valid =)sdigit and is 4. digit
paint C is_valid) op» Taue
oineawise, False
“'pn = “agua”
is digit - Piniisdigrt C)
| 1S a.digtt = C lencpind = =4)
we hove +5 7errove cpaae oe is |
3
j
4
é
i
i
iS vad = 16. chgit One 1S_4_degit
pa ae aay Hints ovate) b:- False
cad in = ” 5 —.
Rav;” " oS el
Vi Paint Cpin. Iedigitc >)
ee ;
BACHH 3a1 0)” i =
PM ="lnaniuge’” |
« i ! PRG pin. ISdignec > de
Mobile 1 _ IACSHS2I1g ) —- +
Mobile a = “Qese5y3210”
eiSame = Crnobie_t
Paint Cis_Same)
== Mmoble_2)
OlP- Fatsewr
uw
VSeVyw_spvsonovoovovasenvewevwvwwvwwrr7
StsipC) :
> St3_Yax . StvipC)
Rerraves att the leading and
~toarling spacer -fern a sting:
> StO_VO¥ - Stvip Cchaas)
We can also specity Characters
that Need to be wernoved:
— Removes Bpecipied Characters
that axe leading a “trailing
_, Removes an space, commac
and -futl StoPC: ) that lead A
pail the stoing :
|
las soy ,thaeS Q Spelling mistake’
In Q cocurnent
tae hove 40 Veplace “Seb” wht te
Comet Bpethng:
Seplacec )
Sté_Nos - Beplace Cod, new)
Guesa neo sting after teplacing
ON the CccUrENCes Of the Old Subshing
Wt the Neco sting.
Lets ay wae have-tp Check the Quen
ORL ta Seane ORL
ye hove “to check Wo the Input 1s Starting
ont reps [| de
rome = home. stip C",- 7)
Port Cname) IP* Bavi
eb cat and teh thay”
. Inetps : | Jonthagornoslet con *
«
moble = 98 1G5H 3210,
Mobile = fnabile. stepC )
pant Cmobile?) aeresian
hore = Ravi.’
Name = narme.stwpcC".”)
paint Cnarne) o}P Ravi
name = ..M+Ray}..”
Tame =rame .stupC". ")
Ponkcrame) yp,
M- Ravi
u
| More- 5 ..,,Zavi,....”
eee cat and “teh cbg”
aS ee 5
+ the’)Stasis wth ¢ >
Std_Vas. stastswrth Cvatue’) ut =" https: ] etbaqorrodt cere
Gwes Toue 4 te Sting starts 1m
the Specified Value
Otherwise, False
POINEC IS Seouse’) oP Toure
Lets soy we have 40 check -the input quer
by a user if a Grail ID:
”
r paiyal234@ grnail- can
woe have to check Hy) the Input 13 ending
\Olth “@grail tn
endswith C_) : St3_Vas . endsiwith Cvalue)
Qrmail_id = “peryare34 @grai-.cn
| is_qreail - grral_id- endeavors C‘@qrail-com )
pantCis.qral) "Thue
lets say te hove to teed Username to +t 1) AN appiicatin 8m
yohatever might be the uses YW put, we Want to Convert the Sting —to Upperaare
Upper C > + 2t6.\00. upper C )
Gwves or Uppercase String of Quen sting
shame = “ray” i
: , Part Cname.. upperc 9)
locos ) RAV? “Apple” Py
\ 7 .
Povi Opple
Stoirg-Vasiahie sleare1¢ 5)
Pee “Ravy”
Pant Cname. laser¢ ))
orp.
We
cr
|
|
4
15 Secuse = Url Startscoib Chips
(
{
(
(
‘
(
4
‘
«
c
¢
«
<
<
«'WBVBUVOHOTHVVVIVOVOHOH00H000 0048000646656 56 4
Fo we Stang Methods -
+ Classification methads
e iSalphac )
© iSdearnalc )
© eleaderC)
° 1S Upperc )
e is atnumc)
. Case Conversation Methsds
e Capitalized >
© titled )
° Scoopcasec >
x Counting and Searching methods
o Cant)
° indexc )
© ~sindesct )
© -findc)
© tfindc?
Classrficotan sethods :- These metrods are usedito Check=the Charactenstice of
indivcual characters IN A stung -
=> qwes tue Wp alithe Charades Ore alphabet .Othenwite, False.
ext: | 1s.alpha ~ " Paya 'sabphae
oe Cis_alpha’) olp: Tue |
J
a- | is_alpha ~ " paya@19345", lenghac ) \
| pontCis_alpha) olp:- Fale
iSdeumel ;- |sSte vas. isdecirnalc 9}
> ves -tue iF an characes ate Ceamals. cthearc, Fake.Br: wodd = “ 9946543aI0'. igcbarmalc )
pant Cuca) o|p- Toue
Wact = "193.p". isdeamalc )
Pent Cwed ) o\p:- False
iSlomes :- |Std_Vas. islocwe:C )
> ques Foue # ali lee’ im the sting are Ip lowercase. otherwWie Falke
Ex: is locacs = “hello Paiyal . islowerC )
paint C \s_tocser) o|p:- Toue
ig locces - HI Rani’ istecaev )
| poirtC iS_tecxes) ——opr- Fate
a
{Suppes += |St® yas « isupperC )
> qwves tsue if atl lets Ina sting axe in UPPeicase . OtbewWike, Flas.
ex:- | is_upper - HEtLO PRIA! °. Supper C )
PrimtCis_upper ) Ap: Tsue. - ,
/5_upper = “RELLO PRIYAL » isupper(
pantCis_uppey) olp:- False
isatnury = |StO_ Vass. igainumc )
> Qves true HP the string 18 alphanumenc Ca leter oy o
Number - Olhewone, Fatse-Bx:- | 7S_alnum ~ “Rahulla3-isalnuec )
paint CiS_a\nurn) Api Toue
{o_alnury = " Rahul: isalnurnc )
PsintCis_atnurn) olp: Toure
is.alnurn = "Rahul@ 123 . isalnurre )
psintC (S_alnurn) olp'- Fatse
Case Conversia Methods
“These nettods are used to change the case g a sting:
Captatize :- |sta_Vas. capitaizeC )
> ques a hee sting after canwerting the -Pinst letter In the
sting +0 uppercase and av other letters to (o@merCase.
Caprtahized . “the planet Eovth’ capitalized ) |
pant Ccaprialized )
title «_ [ats_vaw titled )
> queso read String after Comerting the frst lettey g
ety wood to Uppercase.
—> B % Wad Contains a numba A a Spscial Character
Ape first letter after that 1b Cawerted +o Uppercase i
Ex:
olp!- The planet earth
$$
Ex:- |-+itte_case = the planet oe recs,
pork Cte case’)
OP The Planet Faxth
ds
\
case = “My_Marnett ts iisheseioa Ond | Love. python:
nt Clitle_ case )
o\p- My Namet#75 Johnipoe And T Love i |Std_VOw . Scanpaase C }
=> Gives a Neco sbing afte carerting tbe Uppercase letters
SwapCase
-to locdescase and Vice_Versq
Ex: | Swopped = “MY NAME TS {AVI ” Swopcasec 1
PantCsvaapped ) Olpi- My Name is Ravi
Counting and Searching Methecls
-» These incthads are uSecdi-to Count the Occunences
ok a substirg in a Sting and +o ind the Pasitin oF a
Gubsting in a sting:
Count [sees count Csts, start_Index, erd.indes) |
> Here, the start_indesxc and end_index are optcal:
5 The Counc) tretbod gives the number gq times the Specified
ating St8 APpsaKs In the ating: St Sanches the campicte Sting
aa Cejputt :
> 4 start_jnder and end index axe provided, H Searches
between -these indices The end index is not Included.
“Hello, world:h”
ex;- | text =
| letey_count = text CountC"l)
} | pant Cleter_count )
\ pec elites : lie )
text = “Hello,word |”
letiev_ count = text.count C"U 2, 10)
Pant C letter_coumt) op 2wwevsewvevsevJdsevevevevevwevvewewrverewvwrvwre~w
ngiese <= [St6_vos- index Ceti, ctart_indexe, end_inder)
— Hese, the staxt_index ard the end index are opticnal
— The indecct) rmrettod ques the index at the first Ccaumence q the
Specified string sti:
— M wesutts in ah enor if the Speci-fed String ste is Not -found
> The Wdexc) meth Seaches the Cemplete sting as clyoult De
Stast_\ndesx and end_index are provided, Scarches betas
theese IMdies: The end_index 6 not Inoluckd-
ex: [text = “@ hae a spare Fey, if T Lose my key”
| word _indesc = text - index C"Key")
|paimt (wad index) lp 15
.
ae = ‘Coo Coo” |
| wad index =text. indexc C'coe-3,6 )
pont Cwod_irdese) o\p- 4
wWOd index = text -\ndexeC "ha" )
pomtCwod index’) olp!- Velue Exror: Substring rot found
Sindee +- — lato _vas. vindexr Cate, start_index, end_incex)
DINGS
=> Here, Start _Index and end_irdex are cptenal.
— be tindexc) QINGS the Indcler at the last oCcunence Of the
Spaced sting ato-
—> fe Sesulte IN aN emor HP the Specified sting te Ss rot turd.
she index) searches the canplete sting aS deautt- LP
_"
giart_Index ad erd_Inckx Gre provided , Searches
ete ind Te And nate a not Inctuder.Ex: | tect . @ havea Spme key, if ® lose my key”
WB\d_ indese = text: Binder C "Keap”)
paint Cward_index) oIp!- 33
tert . “Coo Coo Coo”
WAd_indew - -besct: Sindee Coco, 3,10)
point Cwad _ Index) op- @
4exct = ‘Coo Coo”
whd_ Index = text. Bindex C"ha)
paint Coed_ index) o|pi- Value Enon: substing not—fund
Find ee [sos tind C ste, cart inekes tr incee)]
> Hese, the Start_index and énd_incer oxe opticnt.
The -findc) ques the index at the fst cCanence q tre Specs
GksI0Q sto:
— &f the Specified sting Sts 13 not ound jt webeng —I.
.
The find ©) Searches the complete sting OF Cejault. De
statt_\nder and end_index are provided, Ht Gearcheg betoen
orese Indices The €nd_index IS Not tncluded.
—> Bt wake similarly to the indexc)?. The aly diffecnce is thou
spe IndexcC) sesult~ {mn an enor Hy the Specified Sting ts not
-fourd ; while -findc ) does not»
—_
text = “@have a Spane key, f M lowe my key”
VB _index . ext : -Pind C'key")
pant CWSd_ Indes’) — olp.- 15
HOI me Cao aan
Wed _incesc = +text+find C'co! 5, ¢)
Paint CHa _ trey ) Olp- 4PUCSEt =" “ESO, CoO
word_indese = text. find C*ha")
paint CwOd _index) ap- - 4
Yfind + std var. ¥And Cats, atort_indesx erd_index )
-y Here, the staxt_incdex ard the end_indese are optral:
—9 The Bind) gwes the Indes: at the lost Ocauvence CF the
Specrfied stsing ste
—> DP the specified Sting sts 1S rot -fournd, 1+ seturns -I-
—» the Gfirdc) Sanches the carptete sting 0% Cepaurt - SF
Start index and end_index axe provided, H Searches betescery
shez Ialicer The erd_inder {8 Gt Included.
—> GF wGhs simitasty To the Vindlexrc ) The aly differance
that the Winder) “sults IN an enor H the Bpeci-fed
ea 18 not Pound, hile Pndc) ces mot:
Eo:- | -+text= @D have a Spare key 1f @ ae my ey” =|
wod_index = text -tFind C"key”)
pantCwad trex) olp- 33 ; al
text = ‘coo c00 coo”
wo8d_tndex = -teact %-Find C co) 3, 10)
part Crvodd_inceae , op 3
-text = “coo ah
VeBd_ these = eset find Cha")
Paint CxBid_trdexe) ofp. —4Delving ond Webuggng tort -3:-
© Sting Pattern + Gren a shing,tovte a program to pint sutsnngs in expected
© pattern of Ni vexat, where NB the lergibg, the sting.
hput
Ghput fewnat °- Ast Une voit Conain a Sting. Rahul
cutput fowrat © pant chnactes in enpsced patie.
Appeach = S= PRO) HT otine
‘(pmcscup OR 4
part COC a9) Ra ie
& pants 0.130), Rohs Wer,
Ow Rp Robe 0,
‘
‘
(
‘
‘
(
‘
{
:=~ ~w~T wwewVsTFT TFT vVTrevrwvry wD
jo
® Haug ple Biking (Atkeo in. -fercebook, Micoseyt )
goinde
Given a sting S and N integers, wher N Is 5
I
the length qG_ the Sting Ss: a
3
prt the Sting after shu ling the Choracteys 0
as per “the Order OF the Integers given: Qutput
Coding
Explanation :- goinde ss goinde”
5
1 v
4
2 ce ‘ O sy
3 coding
0
Qnput-fomat:- -fist hne contain a siting of length N Qnput:
abe
“The exciNhines ill Contain an imteger IM cachline °
\
s ; 1
Qutprt-fornat '- pant shurtted sting utp
abe
ch .- Se Input) Shput
Appeach Pe , —_
churfied_& = “* 1
Shuffled _s= sheffled.s+sc1I 4
chutftal_s. Shuffleds+s(2J sax i cutout
chuttled_ce shuffledce C3) i) © non eS
ye
Shutfled _s~ Shuffled.s +904]
shuffled «= shuffled s +S[o)
paint Cshusfied_¢’)
sing hoop :- S = Input) © S= Inparc)
® lens ) Output!
Shureed s- SCincex’)+ chufeted_s egarni
pant Cchupeted_S)
© Pame number +
Wntte a parm “fo pant Hy the given number ts Panne nurnber - oe
5
Note:- “4 pame number is divisible by only Mey ancl |. ae
Qnpstfomat :- fret Ine vad Comiain posrbwe Integer Pea.
Ss
output fount: Sh He Inpt & Panne, ee
part PrirneNumber . Othenase, part Not ct Poirre ‘Nurnber
pame Kumber- Gnput:-
4A
: turdéKebaty —” Ouatpat
. aes Ye wey noe Ne al Net ©. perme umber
eae » nur
-for i in ange C2, n) 7 + Be@maircler —» o 4 fecetene
Wei albu! bel Pht Ceteludirg 1
wcn%i==0)% ; ( , itseip )
-foctens —factows +1
iP factors == O°
er C’pame Nusnber’)
else ‘.
pantC Not o paurne klumbe )
Aa Aa Aa Aza APossible mistakes! —» fe int Cinput CY)
= factow = O
for i inwarge C n>) . 3
WeCNh ie =O!
Outpt
eon Facto = facto + | Not a parce. Number
| : iP factors = = 0! ‘ ' ’
ej paint C'parne Nurnber’)
e)se'
pant "Wot ct Parse Nurnker)
(ested doops:-vn inner Loop ttan the cephated block of on outerlcop 5 called Nested Loop.
= The wnneloop wit be excecuted Me sire “for ach theratin af cus loop:
Br erm 1 Sequence : —— > Outerloop
tees
| i j !
a CO tuqiy ) tie Tesbe l
N | ee ome dee eat ae
es
ett 1? Repeating bik 4, cade
i
1 Grrer asp epaating beck.
Cie alort jm weQ) Fangutos Rattern vo Numbers
Worte Q. peagram -to part a TaiargularRetterr both Murpbers in N woos, where
irrtegay N18 Given as inpet : i
Ghpat fownott'- -first bine will Corpain a made
Qutpt format: Pint a tiangulay partes Kh a
ee
pjote- There 16 a spate aftes e@exy number (ow hs
— ; loo 3 +
Approach :- oe /
u 6
weil pe ty stays “stay ae
© yroeewkies ek et dae behoeres ap icy cecep j
|
. die t { 1 { 2
4 cled rose)
Nur = ineCinputc)) ; }23y i
. BAe Kia ! » 3 45
Re weE~_LNUPH IH ange Ct, NUM+N* HPaocax—» - efor Han in Sequence.
Pee F pio
while condiim: Also Include while
'
'
“loop in for looArcep Aenbrel Ditatiments:
if—elif—else
Utter the sequential execrtn GA Program while, Br
bseak, continue
Bozok +--+ mokes the paagram exit a loop early. _
> Generay, beeak 1S Used to emit Q 2
loop when canditin is =ma
yy “V0 olp:- End
while icta.
beak
paintcid
pel
paint C“End’ )
XY +o 1 in ange cio): olp:- Syntarc Exton :
"outside ti
point¢ dD “peeak) outs Cop
baeak
paintCend”)
Bacals In_Nestecl Loop: -
-y Byeak In innes loop Stops the excecistian of the Inner loop:
tx: fo5 @ In ange Ca): tei)
pant Closter : yatu(a),
“or pn mange C)* au
ip b= <1;
ipoeak
paint inner. 4.chcb)) at te
OP giter 1 0 ‘ all Lee + Je
nes: ©
outes 1.1
inned : ©
he iter In Sepeicsh:
=
te ae
Q first wad in Upper Case
J
TT
Ey
YUL OU S| DIY doo} EPisyNo Peooid si 4
doo) ey- 2 coo] aim apIcUA PFSN st Hood
i
Given a sentence, printa mecd sentence Uatth the fist wad iM OpperCare .
Pytion§ is a psdgaamming lanquage-
utp
PYTHON Is a Psogoaraming tonquage x