Problem Solving Python Programming

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

PROBLEM SOLVI

NGPYTHON
PROGRAMMING

1.MENTI
ONTHERULESFORNAMI
NGVARI
ABLE?

 Al
lvar
iabl
enamesmustbegi nwithalet
terofthealphabetoran.under
scor
e(_)..
..
 Af
tert
hefir
stini
ti
all
ett
er,
vari
ablenamescanal socontainletter
sandnumber
s...
.
 Upper
casecharact
ersar
edisti
nctfr
om lowercasecharacters...
.

2.DEFI
NEMULTI
PLEASSI
NGNMENTWI
THANEXAMPLE?
Py
thonal
l
owspr
ogr
ammer
stoassi
gnasi
ngl
eval
uet
omor
ethanonev
ari
abl
es

Si
mul
taneousl
y.

Forexampl
e:a=b=c=1
Her
e,ani
ntegerobj
ecti
screat
edwi
tht
hev
alue1,
andal
lthr
eev
ari
abl
esar
eassi
gnedt
o
t
hesamememor yl
ocat
ion.
3.DI
FFERENCEBETWEENLI
STANDTUPLE?

LI
ST TUPLE
Thel
it
eral
synt
axoftupl
es thel
it
eral
synt
axofli
stsi
s
1. i
sshownbyparent
heses{}
.shownbysquarebr
acket
s[]
.
Asal
i
sti
smut
abl
e. Tupl
esar
eimmut
abl
e.
2.

I
tcanchangest
hev
alues. Thismeanst
haty oucannot
3. changet
hevaluesinatuple
onceyouhav
ecr eatedi
t.

4.LI
STDI
FFERENTTYPESOFOPERATORSI
NPYTHON?

 Ar
it
hmet
icOper
ator
s

 Compar
ison(
Rel
ati
onal
)Oper
ator
s

 Assi
gnmentOper
ator
s
 Logi
cal
Oper
ator
s

 Bi
twi
seOper
ator
s

 Member
shi
pOper
ator
s

 I
dent
it
yOper
ator
s

 Unar
yOper
ator
s

6.DEFI
NERESERVEDWORDS?
MENTI
ONANY5

I
nev eryprogr
ammi ngl
anguaget
herear
ecer
tai
nwordswhichhav
eapre-def
inedmeani
ng.
These
wordswhichar eal
soknownasreser
vedwor
dsorkeywor
dscannotbeusedfornami
ng
i
dentif
ier
s

Reser
vedWor
ds:

And,
or,
not,
eli
f,el
se,
for

7.DEFI
NEDI
CTI
ONARY?
THENASSI
GNDI
CTI
ONARYI
N5VALUES

Python’
sdicti
onari
esstoresdatainkey-
val
uepai r
s.Thekeyvaluesar eusuall
ystri
ngsandv alue
canbeofanydat at y
pe.Thekeyvaluepai
rsareenclosedwithcur l
ybraces({})
.Eachkey-
value
pai
risseparatedfrom t
heotherusingacolon(:
).
Toacccesanyv alueinthedicti
onar
y,y
ouj ust
needtospecifyit
skeyinsquarebraces([]
).Basi
call
y,di
cti
onariesareusedf orfastr
etri
evalof
data.

8.STATETWOTYPESOFMODESI
NPYTHON?

Py
thonhast
wobasi
cmodes:
scr
iptandi
nter
act
ive.

SCRI
PT:

Thenormalmodei
sthemodewher
ethescr
ipt
edandf
ini
shed.
pyf
il
esar
eruni
nthePy
thon
i
nter
pret
er.
I
NTERACTI
VE:
I
nter
acti
v emodeisacommandl ineshel
lwhichgi
vesi
mmediat
efeedbackforeachstat
ement
,
whil
erunningpr
evi
ouslyfedst
atementsi
nact i
vememory
.Asnewlinesar
ef edi
ntothe
i
nter
preter,t
hef
edprogram i
sevaluat
edbothinpar
tandi
nwhole.

9.DI
FFERENCEBETWEENI
NTERPRETER ANDCOMPI
LER:

I
nter
pret
er Compi
l
er

Transl
atespr
ogr
am onest
atement Scanst
heent
ir
eprogr
am andtransl
ates
atatime. i
tasawholei
ntomachinecode.
I
ttakeslessamountofti
met o I
ttakesl
argeamountofti
met oanalyze
anal
yzethesourcecodebutthe t
hesourcecodebuttheover
allexecuti
on
over
allexecut
iont
imeisslower
. t
imeiscomparat
ivel
yfast
er.

Noi nter
mediateobj
ectcodei
s Generatesintermediat
eobjectcode
gener at
ed,hencear
ememor y whichfurtherrequi
resli
nki
ng,hence
eff
icient. requi
resmor ememor y.

10.DEFI
NEDATATYPE?GI
VEANEXAMPLE
I
ntheprevi
oussect
ion,
wehav eseenthatvar
iabl
escanholdval
uesofdif
fer
entty
pescalleddat
a
t
ypes.Thus,
weneeddiffer
entdat
atypestostoredi
ff
erentt
ypesofval
uesinthevar
iabl
es.

ForExampl
e:

Aperson’
sageisstor
edisanumber,
hi
snamei
smadeofonl
ychar
act
ers,
andhi
saddr
essi
sa
mi
xtureofnumbersandchar
act
ers.

11.DEFI
NECOMPUTER?
Comput
eri
sanelect
ronicmachinethataccept
sdat
aandinstr
ucti
onsfr
om theuser,pr
ocesst
he
dat
abyper
for
mingcalculat
ionsandoperati
onsoni
tandgenerat
esthedesi
redoutput.

12.DI
FFERENCEBETWEENRAM ANDROM?

13.MENTI
ONCHARACTERI
STI
CSOFCOMPUTER?

 Speed

 Accur
acy

 Ver
sat
il
it
y
 St
orage

 NoI
Q

 NoFeel
i
ngs

 Di
l
igence

14.DEFI
NEALGORI
THM .LI
STTHECHARACTERI
STI
CSOFALGORI
THM

Anal
gori
thm isastepbystepmethodofsol
vi
ngaprobl
em.Iti
scommonlyusedf
ordat
a
pr
ocessi
ng,calcul
ati
onandotherr
elat
edcomput
erandmathemat
ical
oper
ati
ons.

15.WHATARETHESTEPSTOBEFOLLWEDTODESI
GNANEFFECTI
VEALGORI
THM?

 Under
standi
ngt
hepr
obl
em

 Det
ermi
ningt
hecapabi
l
iti
esoft
hecomput
ati
onal
dev
ice

 Exact/appr
oxi
mat
esol
uti
on

 Sel
ectt
heappr
opr
iat
edat
ast
ruct
ure

 Al
gor
it
hm desi
gnt
echni
ques

 Met
hodsofspeci
fyi
nganal
gor
it
hm

 Pr
ovi
nganal
gor
it
hmscor
rect
ness\
 Anal
ysi
ngt
heper
for
manceofanal
gor
it
hm

16.DEFI
NEFLOWCHART.LI
STOUTTHESYMBOLSANDI
TSPURPOSE.
Fl
owchar
tisadi
agr
ammat
icr
epr
esent
ati
onoft
hel
ogi
cforsol
vi
ngat
ask.

Sy
mbol Descr
ipt
ion

St
artandst
op

Pr
ocess

I
nputandOut
put

Deci
sionMaki
ng

Cont
rol
flow

Connect
or

Forl
oop

17.DEFI
NEPSEEDOCODE

You might also like