Pyt
honpr
ogr
ammi
ng
I
phoneori Padyouneedt oi ns tall acoupl eofot hert hingsf irstsoyougot ot heAppSt oreand
sear chf orPychar m. Theni nt heAppSt orecl ickont hei ns tallbut ton. Now. OncePychar mi s
i
ns talled, youcanopeni tupbycl ick i
ngont hisi con. Her einyourdownl oadsf ol der .You
shoul dal sohavea. pyf i
le. Sol et 'sopent hatupnow. Thef irstt hingyou' regoi ngt odoi s
creat eanewpr ojects olet 'sdot hatbycl icki ngont hi sgr eenpl uss ignher ei nyourpr oj ect
expl orerwi ndowandt ypei nPyt hon. Thisi st henameofyourpr oject .Nowl et '
schoos ea
l
ocat i
onf oryourpr oj ects owe' r
egoi ngt ochoos eaf olderonourcomput ercal ledpr ojec tsand
thencl i
ckont hecr eat eBut tonNowl et'schanges omes ett i
ngsi ns ideofPychar m. Sof irst
thingyou' regoi ngt o. Towantt odoi schanget hel anguageofyourpr ojectt oPyt hon, So
i
ns ideofpychar m. Got oFi le>Set tings>Pr oj ectSet tingsandi nt heLanguagess ect ion
changePyt hont ot hel anguageofyourpr oj ect .Nownex tt hingyou' r
egoi ngt owantt odoi s
setupyourpr ojectf olders oi ns ideofpychar m got oFi le>Set tings>Pr ojectSt ruct ureandi n
thePr ojectFol ders ect i
oncl ickont heBr ows ebut tonandt hens el ectt hef ol derwher eyou
wantyourpr ojectf ilest ol ives onowYourpr oj ecti ss etupandr eadyt ogoal lrightl et '
ss tart
wr i
tings omecode. We' regoi ngt os tartwi tht hes impl estcodepos s i
bleandt hat '
sahel lo
wor ldpr ogr am. I
nPyt hon. AHel lowor l
dpr ogr am i ss impl yapr ogr am t hatpr int southel lo
wor lds ol et '
sopenupour .pyf i
leandent ert hi scodeher e. Her ei mpor ts ys[ UNK]wor ld!")all
ri
ghts owe' vei mpor tedt heSysmodul eandt henwe' vepr i
nt edout[ UNK]wor ld!"nowLet '
s
saveourf i
lebycl icki ngont hisgr eenbut tonher ei nyouredi torwi ndowandcal litHel lo.py
nowl et '
sr unourpr ogr am bycl ickingont hi sgr eenr unbut tonher ei nsideofpychar m and
you' llseet hatourpr ogr am haspr i
nt edout[ UNK]wor l
d!"al lrightt hat'sourf i
rs tsimpl ec ode
blocki nPyt honnowLet '
st akeal ookats omemor ecodebl ocksi nPyt hon. Firstt hingwe' l
l
wantt odoi scr eat eavar iabl e,s ol et'sopenupourhel lo.pyf i
leagai nandent ert hi scodedef
[UNK][ UNK]wor l
d!")al l ri
ghts owe' vedef inedaf unct i
oncal leds ay—hel l
o( )andi nsideofs ay
—hel lo()we' r
egoi ngt opr intout[ UNK]wor ld! "nowl et'ssaveourf i
leonceagai ns aywewant
todecl areavar iabl ecal l
edpr ice. Wewoul dt ypepr i
ceandt henaf terwet ypet henameof
thevar iable. Wewoul dputacol onandt hent heval ueoft hatvar iable. Soi nt hiscas e, the
valueoft hisvar i
abl ewi ll be1 2.99. Sowecanus et hisvar iabl eanywher ei ns ideourPyt hon
codenowl et'
ss aywewantt opr intt heval ueoft hisvar i
abl e.Wecandot hatbys impl y
wr i
tingpr intpr iceandt henaf tert hatwewoul dputaper i
odandt hent heval ueoft he
var i
abl e. Soi nt hiscas et hecodewoul dpr intout1 2.99al right . Nowl et'ss aywewant edt o
changet heval ueoft hisvar iabl e. Wecandot hatbys i
mpl yt ypi ngnewval uef orpr i
ceand
thenaf tert hatwewoul dt ypeacol onandt hent henewval ueoft hevar iabl e. Soi nt hiscas e
thecodewoul dpr intout1 3. 00al right .Nowl et 'ss aywewant edt odel etet hi svar iabl e. Wecan
dot hatbys impl yt ypi ngdel et epr i
ceandt henaf tert hatwewoul dt ypeaper iodandt henhi t
ent ers oI nt hiscas e, thecodewoul ddel etet hevar i
abl ecal ledpr iceAl right .Nowl et '
st al k
aboutl ists.Let '
ss aywehaveal istofi t
emsandwewantt odi spl ay. eachi tem i nt urnonour
appl icationwi ndows otodot hatweneedt ous eaf orl oops ot odec l
areaf orl oop. Wewoul d
typef oritem i nl is
t ,andt henaf tert hatwewoul dt ypepar ent hes is, t
hent hel i
s titem andt hen
aftert hathi tent ers oI nt hi scas e, thecodewoul dr unf oreachi tem i nt hel is tcal l
edl i
s tand
honpr
ogr
ammi
ng
I
phoneori Padyouneedt oi ns tall acoupl eofot hert hingsf irstsoyougot ot heAppSt oreand
sear chf orPychar m. Theni nt heAppSt orecl ickont hei ns tallbut ton. Now. OncePychar mi s
i
ns talled, youcanopeni tupbycl ick i
ngont hisi con. Her einyourdownl oadsf ol der .You
shoul dal sohavea. pyf i
le. Sol et 'sopent hatupnow. Thef irstt hingyou' regoi ngt odoi s
creat eanewpr ojects olet 'sdot hatbycl icki ngont hi sgr eenpl uss ignher ei nyourpr oj ect
expl orerwi ndowandt ypei nPyt hon. Thisi st henameofyourpr oject .Nowl et '
schoos ea
l
ocat i
onf oryourpr oj ects owe' r
egoi ngt ochoos eaf olderonourcomput ercal ledpr ojec tsand
thencl i
ckont hecr eat eBut tonNowl et'schanges omes ett i
ngsi ns ideofPychar m. Sof irst
thingyou' regoi ngt o. Towantt odoi schanget hel anguageofyourpr ojectt oPyt hon, So
i
ns ideofpychar m. Got oFi le>Set tings>Pr oj ectSet tingsandi nt heLanguagess ect ion
changePyt hont ot hel anguageofyourpr oj ect .Nownex tt hingyou' r
egoi ngt owantt odoi s
setupyourpr ojectf olders oi ns ideofpychar m got oFi le>Set tings>Pr ojectSt ruct ureandi n
thePr ojectFol ders ect i
oncl ickont heBr ows ebut tonandt hens el ectt hef ol derwher eyou
wantyourpr ojectf ilest ol ives onowYourpr oj ecti ss etupandr eadyt ogoal lrightl et '
ss tart
wr i
tings omecode. We' regoi ngt os tartwi tht hes impl estcodepos s i
bleandt hat '
sahel lo
wor ldpr ogr am. I
nPyt hon. AHel lowor l
dpr ogr am i ss impl yapr ogr am t hatpr int southel lo
wor lds ol et '
sopenupour .pyf i
leandent ert hi scodeher e. Her ei mpor ts ys[ UNK]wor ld!")all
ri
ghts owe' vei mpor tedt heSysmodul eandt henwe' vepr i
nt edout[ UNK]wor ld!"nowLet '
s
saveourf i
lebycl icki ngont hisgr eenbut tonher ei nyouredi torwi ndowandcal litHel lo.py
nowl et '
sr unourpr ogr am bycl ickingont hi sgr eenr unbut tonher ei nsideofpychar m and
you' llseet hatourpr ogr am haspr i
nt edout[ UNK]wor l
d!"al lrightt hat'sourf i
rs tsimpl ec ode
blocki nPyt honnowLet '
st akeal ookats omemor ecodebl ocksi nPyt hon. Firstt hingwe' l
l
wantt odoi scr eat eavar iabl e,s ol et'sopenupourhel lo.pyf i
leagai nandent ert hi scodedef
[UNK][ UNK]wor l
d!")al l ri
ghts owe' vedef inedaf unct i
oncal leds ay—hel l
o( )andi nsideofs ay
—hel lo()we' r
egoi ngt opr intout[ UNK]wor ld! "nowl et'ssaveourf i
leonceagai ns aywewant
todecl areavar iabl ecal l
edpr ice. Wewoul dt ypepr i
ceandt henaf terwet ypet henameof
thevar iable. Wewoul dputacol onandt hent heval ueoft hatvar iable. Soi nt hiscas e, the
valueoft hisvar i
abl ewi ll be1 2.99. Sowecanus et hisvar iabl eanywher ei ns ideourPyt hon
codenowl et'
ss aywewantt opr intt heval ueoft hisvar i
abl e.Wecandot hatbys impl y
wr i
tingpr intpr iceandt henaf tert hatwewoul dputaper i
odandt hent heval ueoft he
var i
abl e. Soi nt hiscas et hecodewoul dpr intout1 2.99al right . Nowl et'ss aywewant edt o
changet heval ueoft hisvar iabl e. Wecandot hatbys i
mpl yt ypi ngnewval uef orpr i
ceand
thenaf tert hatwewoul dt ypeacol onandt hent henewval ueoft hevar iabl e. Soi nt hiscas e
thecodewoul dpr intout1 3. 00al right .Nowl et 'ss aywewant edt odel etet hi svar iabl e. Wecan
dot hatbys impl yt ypi ngdel et epr i
ceandt henaf tert hatwewoul dt ypeaper iodandt henhi t
ent ers oI nt hiscas e, thecodewoul ddel etet hevar i
abl ecal ledpr iceAl right .Nowl et '
st al k
aboutl ists.Let '
ss aywehaveal istofi t
emsandwewantt odi spl ay. eachi tem i nt urnonour
appl icationwi ndows otodot hatweneedt ous eaf orl oops ot odec l
areaf orl oop. Wewoul d
typef oritem i nl is
t ,andt henaf tert hatwewoul dt ypepar ent hes is, t
hent hel i
s titem andt hen
aftert hathi tent ers oI nt hi scas e, thecodewoul dr unf oreachi tem i nt hel is tcal l
edl i
s tand