Transcription of Real Python: Python 3 Cheat Sheet
{{id}} {{{paragraph}}}
Real Python : Python 3 Cheat SheetContents1 Introduction22 Primitives3 Numbers..3 Strings..5 Booleans..73 Collections9 Lists..9 Dictionaries..114 Control Statements12IF Statements..12 Loops..145 Functions151 Chapter 1 IntroductionPython is a beautiful language. It s easy to learn and fun, and its syntax is simple yet ele-gant. Python is a popular choice for beginners, yet still powerful enough to back some of theworld smostpopularproductsandapplicationsfromc ompanieslikeNASA,Google,Mozilla,Cisco, Microsoft, and Instagram, among others. Whatever the goal, Python s design makesthe programming experience feel almost as natural as writing in Emailyourques-tions or feedback 2 PrimitivesNumbersPython has integers and floats. Integers are simply whole numbers, like 314, 500, and , meanwhile, are fractional numbers like , , You can use the typemethod to check the value of an >>>type(3)2<class 'int'>3>>>type( )4<class 'float'>5>>> pi = >>>type(pi)7<class 'float'>In the last example,piis the variable name, the can use the basic mathematical operators:1>>> 3 + 3263>>> 3 - 3405>>> 3 / >>> 3 / >>> 3 * 310911>>> 3 ** 3122713>>> num = 314>>> num = num - 115>>> print(num)16217>>> num = num + 1018>>> print(num)191220>>> num += 1021>>> print(num)222223>>> num -= 12
8 1.5 9 >>> 3 * 3 10 9 11 >>> 3 ** 3 12 27 13 >>> num = 3 14 >>> num = num - 1 15 >>> print(num) 16 2 17 >>> num = num + 10 18 >>> print(num) 19 12 20 >>> num += 10 21 >>> print(num) 22 22 23 >>> num -= 12 24 >>> print(num) 25 10 26 >>> num *= 10 27 >>> num 28 100 There’s also a special operator called modulus, %, that returns the remainder after integer …
Domain:
Source:
Link to this page:
Please notify us if you found a problem with this document:
{{id}} {{{paragraph}}}