fr fr fr fr fr
Whatfrdofrvariablesfrdo? Afrvariablefrstorefrsomethingfr(value,frobject,frwhatever)
Whatfrarefrthefrrulesfrforfrvariablefrnaming? 1.frCan'tfrstartfrwithfrnumbers
2.frCan'tfrusefrkeyfrwords
3.frNofrspaces
Placefr'good'frnextfrtofreachfroffrthefrfollowingfrgoodfrvariablefrnames.frPlacefr'bad'frnextfrtofrthefrbadfrones:
1.frvar
2.frtotal_number_of_students_in_the_room_ZACH_210
3.frsum
4.frMaclaurin’s
5.frinitial.frPosition
6.fr36_array
7.frBigfrchonk 1.frbadfr(hasfrkeyword)
2.frbadfr(toofrlong)
3.frbadfr(keyword)
4.frgood
5.frbadfr(can'tfrhavefrafrperiod)
6.frbadfr(can'tfrhavefrnumbers)
7.frbadfr(startsfrwithfrupperfrcase,frmemefrname)
Whatfrwouldfrbefrthefrfollowingfroutput?
afr=fr21
bfr=fr(afr+fr4)fr//fr7fr#divisionfrwithfrnofrremainder
cfr=frafr%fr5fr#givesfryoufrremainder
print(b)
print(a)
###################
xfr=fr3
yfr=frx
xfr=fr4
print(y) 3
1
#####
3
Listfrthefrfourfrmainfrdatafrtypesfrandfrsomefrexamplesfroffreach 1.frStringsfr(bananas,fr'71',fr'Howdy')
2.frIntegerfr(3,4,-21,22)
3.frFloatfr(4.0,fr7.1,fr-23.45,fr100.99)
4.frBooleanfr(True,frFalse)
Datafrtype:
tuple Anfrimmutablefrcontainerfrwithfrorderedfrelements
Howfrdofryoufrchangefrthefrtypefroffrvariable? Typecasting.
Usefrthefrdesiredfrtypefrandfrthenfrsomefrparenthesis
Ex.fr.float('72.6')frreturnfr72.6
, Listfrthefrthreefrmainfrconversionfrspecifiersfrandfrwritefrwhatfrthefrcodefrwouldfroutput
1.fr.dfr#substitutesfranfrinteger
2.fr.ffr#substitutesfrafrfloat
3.fr.sfr#substitutesfrafrstring
EXAMPLE:
Listfrthefrthreefrmainfrconversionfrspecifiersfrandfrwritefrwhatfrthefrcodefrwouldfroutput
print("Ifrtoldfrherfr%dfrtimesfrthatfrIfrhavefrafr%.2ffrpercentfrsuccessfrratefrwithfranyfr%s."fr%fr(7,fr92
.8,frdog)
>>>Ifrtoldfrherfr7frtimesfrthatfrIfrhavefrafr92.80frpercentfrsuccessfrratefrwithfranyfrdog
Whatfrhappensfrwhenfryoufrusefrthefradditionfroperatorfronfrtwofrstrings?
'12'fr+fr'12"fr=fr? >>>1212
Howfrdofryoufrgetfrafruserfrtofrenterfrafrstring,frinteger,frfloat,frboolean? 1.Stringfr
user_stringfr=frinput("Enterfrafrstring:fr")
2.Integer
user_integerfr=frint(input("Enterfrafrinteger:fr"))
3.Float
user_floatfr=frfloat(input("Enterfrafrfloat:fr"))
4.Booleanfr=frint(input("Enterfr0frforfrfalsefrorfr1frforfrtrue:fr"))
MATHfr-frOperators
1.fr+
2.fr-
3.fr*
4.fr/
5.fr//
6.fr**
7.fr% 1.fraddition
2.frsubtraction
3.frmultiplication
4.frdivision
5.frfloorfrdivisionfr
6.frexponent
7.frmodulo
RELATIONALfr-frOperatorsfr
1.fr==
2.fr!=fr
3.fr>
4.fr<
5.fr>=
6.fr<= 1.frequal
2.frnotfrequal
3.frgreaterfrthan
4.frlessfrthan
5.frgreaterfrorfrequalfrthan