Transcription of Python 3 Cheat Sheet - LIMSI
{{id}} {{{paragraph}}}
Sequence Containers IndexingBase TypesPython 3 Cheat Sheet 2012-2015 - Laurent PointalLicense Creative Commons Attribution 4 Latest version on : "One\nTwo"'I\'m'str"""X\tY\tZ1\t2\t3""" 10-6escaped tabescaped new lineMultiline string:Container Typeslist[1,5,9]["x",11, ]["mot"][]tuple(1,5,9)11,"y", ("mot",)()dict{1:"one",3:"three",2:"two" , :" "}{"key":"value"}set{}{1,9,3,0} ordered sequences, fast index access, repeatable valuesset() key containers, no a priori order, fast key access, each key is unique{"key1","key2"}Non modifiable values (immutables)Variables assignmentx= +8+sin(y)y,z,r= , ,0 followed by diacritics allowed but should be avoided language keywords forbidden lower/UPPER case discrimination expression with only comas tupledictionarycollectioninteger, float, boolean, string, bytesIdentifiers a toto x7 y_max BigOne 8y and forx+=3x-=2increment x=x+
sorted(c)→ list sorted copy val in c → boolean, membership operator in (absence not in) enumerate(c)→ iterator on (index, value) zip(c1,c2…)→ iterator on tuples containing c i items at same index all(c)→ True if all c items evaluated to true, else False any(c)→ True if at least one item of c evaluated true, else False ☝ modify ...
Domain:
Source:
Link to this page:
Please notify us if you found a problem with this document:
{{id}} {{{paragraph}}}