single line comments start with a number symbol

single line comments start with a number symbol

ID:11483533

大小:59.10 KB

页数:37页

时间:2018-07-12

single line comments start with a number symbol_第1页
single line comments start with a number symbol_第2页
single line comments start with a number symbol_第3页
single line comments start with a number symbol_第4页
single line comments start with a number symbol_第5页
资源描述:

《single line comments start with a number symbol》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、#Singlelinecommentsstartwithanumbersymbol."""Multilinestringscanbewrittenusingthree"s,andareoftenusedascomments"""######################################################1.PrimitiveDatatypesandOperators#####################################################Youhavenumbers3#=>3#Mathiswhatyouwou

2、ldexpect1+1#=>28-1#=>710*2#=>2035/5#=>7.0#Resultofintegerdivisiontruncateddownbothforpositiveandnegative.5//3#=>15.0//3.0#=>1.0#worksonfloatstoo-5//3#=>-2-5.0//3.0#=>-2.0#Theresultofdivisionisalwaysafloat10.0/3#=>3.3333333333333335#Modulooperation7%3#=>1#Exponentiation(x**y,xtotheythpower

3、)2**4#=>16#Enforceprecedencewithparentheses(1+3)*2#=>8#Booleanvaluesareprimitives(Note:thecapitalization)TrueFalse#negatewithnotnotTrue#=>FalsenotFalse#=>True#BooleanOperators#Note"and"and"or"arecase-sensitiveTrueandFalse#=>FalseFalseorTrue#=>True#NoteusingBooloperatorswithints#Falseis0an

4、dTrueis1#Don'tmixupwithbool(ints)andbitwiseand/or(&,

5、)0and2#=>0-5or0#=>-50==False#=>True2==True#=>False1==True#=>True-5!=False!=True#=>True#Equalityis==1==1#=>True2==1#=>False#Inequalityis!=1!=1#=>False2!=1#=>True#Morecomparisons1<10#=>True1>10#=>False2<=2#=>True2>=2#=>True#Comparisonscan

6、bechained!1<2<3#=>True2<3<2#=>False#(isvs.==)ischecksiftwovariablesrefertothesameobject,but==checks#iftheobjectspointedtohavethesamevalues.a=[1,2,3,4]#Pointaatanewlist,[1,2,3,4]b=a#Pointbatwhataispointingtobisa#=>True,aandbrefertothesameobjectb==a#=>True,a'sandb'sobjectsareequalb=[1,2,3,4

7、]#Pointbatanewlist,[1,2,3,4]bisa#=>False,aandbdonotrefertothesameobjectb==a#=>True,a'sandb'sobjectsareequal#Stringsarecreatedwith"or'"Thisisastring."'Thisisalsoastring.'#Stringscanbeaddedtoo!Buttrynottodothis."Hello"+"world!"#=>"Helloworld!"#Stringscanbeaddedwithoutusing'+'"Hello""world!"

8、#=>"Helloworld!"#Astringcanbetreatedlikealistofcharacters"Thisisastring"[0]#=>'T'#Youcanfindthelengthofastringlen("Thisisastring")#=>16#.formatcanbeusedtoformatstrings,likethis:"{}canbe{}".format("Strings","interpolated")#=>"Stringscanbeinterpolated"#Youcanrepeatthe

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。