Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
12 views

Python Notes 2nd part

The document discusses various programming concepts and methods related to functions, dictionaries, and data manipulation in Python. It includes examples of defining and calling functions, built-in dictionary methods, and handling user input. Additionally, it covers topics such as calculating digit sums, checking for prime numbers, and determining even or odd values.

Uploaded by

aniruddh2573
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Python Notes 2nd part

The document discusses various programming concepts and methods related to functions, dictionaries, and data manipulation in Python. It includes examples of defining and calling functions, built-in dictionary methods, and handling user input. Additionally, it covers topics such as calculating digit sums, checking for prime numbers, and determining even or odd values.

Uploaded by

aniruddh2573
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

elASSMAte

Date
Page

SET CExha Gk)


Bul im fumchon

1 e m Csel)
a ma (set)
3minCset)

S toxted Cset)
6Omy Thue false

Cu'lt fn Sc meHhods

N 1set.agdd Cob) -inseat


set tmove (obj)
3se pop Cobj)
set. umiom CcedL, set 2)
5set updlaBe Cseq)
6 Se. inBersethom Cseq

202 Diclion ane


Concept ol olicionatuu
hib
lechmiquei to Catate
pdodle_amd oledele dikionanyÍttms 03bbjcc
lap-aaa.ay Chn)
Buil-m_dicfonay umdion
Bl-Po diclibnay mehoDS hddiion al
tuoo mahi1
Ruhtaao
diCHonau
m p o a e Tuple, List Ond mdinulHp
n hodu tlon 2 Shing Ca
ASumio yple

3 Ezample o l i c

Cum Ho
Value
Key

CName Ram
value
DitHonuuy intluda Key Ond
valLepolXS
sequemtc.of key
olthed
m.br
bxadkek.uoL%eath Mem beina o
haldo be LoiHem.usina pcuy In Hhe forw
Ht

S No1o AueNaQe 090


DIName''Rom
when w t h a u e a a q g e a m . o i n t a t e
1 i s qtmealy ultd
dada.
we mutt Kmou hu key o chleue Hhe.valu CHindion.olKe
Value COm beo 0my yp.e.
sinq
Keug oMe usuauymumbeas 0v
Sundax
DI:Ryaue f
1 Pint Ompleke dichonay
printCDI)

a ini a Hhe Keus ctszi


pintCDLKeys C))

BPinl all he valuu


pHntCDLsalue O)

Bull-i dieionay umthon

1LENGTH Lns Jemgm olHhe didiomosu

printCJtm COD)

RTyPEthe mtlhodype tkinnl he ype ol paised


vaiables
type
/Psh Mahesha
mo d4
2022.12.01 16:03
Date
Page

L-12
DI Nlome1 Mahesho, Masks : 90, Auer.agel : 40.xj
LiL Mahetha 0, 90.SJ
T Mahtha, 0, 905)
SI Mahesho 90, 905)a al aan naiihah
pint ype Csh
paintypeCmo))
pintypeC)
pntHype C01)
pint typ.CL))aiaan hd ada ua
pimtHype CTD)
paint.Ctypc.CS1)2 mn lnuaaalad u
ole

Bwlt-in dictionay mehodt haiiancat


laibuotdollaz aha
1dict.cleasC) -tmovelalielem.trmtof dicioxn@oy
dict Name Mahesha MaaKs' 0Aug'90.5
pintCdict. dean u e al
ahnend
Keys in dicionay
adic. KeugC )-Teums tiso
print Cdich.KeysC))

3Guct.valuea C 1ekusne a he alue of e didt omcuy


pant Ldicd.valuea)

2022-12.0116:03
Date
Page

dicl opyC)stlunnt
Ait2 did..copyt)
pHnt Cdict 2)

ditk.NemsC)1ekum a us o drcllondu uple poiz


Le CAlbmeMaheshoCSTNo0)

ntkon Unil
Pssignment
R O0irplay tablt o Inpp Hed mo. uinq uwhileLoop D
o les
u ok a unHon Jo calulate digil sum af lnpuded no
wite a umdhom Qenencte rwte n0 omn n putLed mo.
H
uo witt a umhon olisplcuy pHmR n0 0 m0t
H wHle o lundlon 4o dstplau mea ol Cirde01 0 O Squont
Hu AustH de lined umcho-n 40 calcuu cuhe aea o e tamale oy

iangle
wile a lumuion he nputHed 0. i bin0y 0r not
Ho Lle a umdHon Ho int Jem 0 npuHed ahing
H Wile a umcHon couni mo 6wods im impukted Shlmq.
R-0 wAF o theck npuded mo is palnd ome O not.
AE Ho dheukimpuded no is onmthonaer mbt i
H OAF o altulade la to cu mo
H AP o cheuk inpukled shing ir palindaome omot
H-O AF to CoumB moo f vowelom npuled stima
HFimd out mim & ma flo imputed noalo
H wAF 4o theuk imputed sping is hexadc.umal
ox mot

if -ele mede d i.elke

L0dd amd utm ul ar


& MO no
u l 1t
3. Min o mo
lassmate

obuodce
Maoc of 3mo
5 md Max o 3 n0
6 Min of 3 m o
Leapyea
8 No iSHVe of ve
9 Alphabet r mot
LO Vowel bx tomsomamt
SSMAt
Date
i/12/202 union Omd module Page

1Tnboductfon
omd mehodo
leatnce blw umtion
aDelining a lumuion
Calling a lum ckfon
68-
5Adromiaqes o fumchon.
Csex delitd omd busll-m Puntlin
Im Rncim
6Type of Aunthon
undion panam eler
(i loimal ponamtln
Actual poramekn
Local amd Gtlobal vaiabled.
afundHon
O Fundhon callmol paing vallLe omdmot etusninq un
Dx funion with mo Qrqument and no tkuin volue
CL) fumcHom ca by pinq value md etimimq alue py
unton uoih aqumemi Omd ekim vauLe
( ) fumdion coul hy pouainq Nalue cMd not ntuminq walue
DY fumttiom with tQumemt Cnd nO thumm value
to Fotamples
deuart md
GWAF o dit play able o inputled mo Callinq isone
olet lable : de lining tunction amdthe R0mt
a:iniCinput Enter mo))
or f im nonqe CL,11 ):_
pintCi*ä)
Hable c Caullinq to Purnthom
wAF 4o toluuladte digt Sum
defdsO: # delhning mdion
a:IndC input ( Entcr no )
dig o
tot 0
while Ca>0)
ASSMAte
Date
Page

adotedottdiq
a all1D
pant Cto4)
dsC) calling o funtlion

6OAE to euenie no.


def 7nC): E delining tumdion
a inCinput.CEnBtomo.))
diq 0

while Ca>o):
Cuq aL10
ewE neVX LO +Cug
a: allio
paint (ntu)
&efanC)# alnq o fumdion

WAE to chetk prime no 0 not


def pmO: # _delininq CuncHon ialalie
o intCinputC"Enler_a no.2))
fo i in nonge(2,oH) iokepihhal
if Cq-0
bneak

ffCi-a):
paintCPxme)a a aalailiai iac
Ue Co uliauaak
pint (Not pime)
pn) # Calllma PumcHon
edsste
Date
page

humion cal bu palltng value om.d usnina value


WAf Ho ChecK odd 01 UemM
delne (s)
(S.2=zo)
Oe

ifCaeso)
pt n
eJie
poAn oodo)
9 Bo caltulade digit sum..
def digit sum
digo
o4:0
while Ca>o):
drq: a10
od dgHot

ottun 4ot
dr'git Sum)
a indCindeqe C"Cntc a no.))
Aot dugiiSuoC a)
pint CHot1
elASSMAte
Date
Page

de x n : de Mntnq dugit
dig
0nhba 1oh
o hile Ca 2o):
diq: a1o
Dnbna
a-a/lio

Tm calling d1git
u
alntinput C"Enttu ano ")
V : 1Ymla)
pint Cew)

oo. ulne Diniina n l a l (ià


pzimttadowal
u d

&OAFto

def CaCa):
fact
fort inomte ti,dH. 2(oanhha h
while Ca2o)
fact fat a
2la
a :a-1
pelusn fat
fnC) ngai
a:int Cinpud C"Enttn al mibaD)
fact n Ca)
p>intCfat)
ASSMts
Date
Page

C unti on eallnot pouinq value but


runni ng Nalue
OAE lo pin odd 01
eum
def eddeutn C
a iniUnput ("E mdcr o mb
tturn Ca/.a)
bddeuemC)
S0ddew tm.)
1fCrt 0):
pintC Even" nai2 aiaan
pintC odd ")

umcHon cau by pcuinq yalue bu


mohekuninq waluE
8wAEo paint odd tuen
def odd ewemC a) h
ifCala==0):
pH nt C" Even ") nlid

PintC"0dd")
0ddev emC)
a iniCin puh ("Emi a
no.) a
tE 0ddewen (aD
classmate
Data

tonP 4o paint rbonicci scittO,1, l. 2,3,5.S, 13

b
CaO
no nHCinpudC Enier no.)
ahile C'Leno) :
C 0b
phimb Cc)
ab 10
b:C O o 2
OL3
2
3 1 2
N

5
13
21 13 4
34 13 1 10

13
21

You might also like