\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Tính Vy (tinhvy)} \pdfinfo{ /Title (python-for-novices.pdf) /Creator (Cheatography) /Author (Tính Vy (tinhvy)) /Subject (Python for Novices Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{0856A3} \definecolor{LightBackground}{HTML}{EFF4F9} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Python for Novices Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Tính Vy (tinhvy)} via \textcolor{DarkBackground}{\uline{cheatography.com/132374/cs/37194/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Tính Vy (tinhvy) \\ \uline{cheatography.com/tinhvy} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 19th February, 2023.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{TOPIC 01: INTRODUCTION}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{- Python Introduction \newline - Getting Started \newline - Keywords \& Identifiers \newline - Statements \& Comments \newline - Python Variables \newline - Python Datatypes \newline - Python Type Conversion \newline - Python I/O and Import \newline - Python Operators \newline - Python Namespace} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{1.1. Install Thonny Python IDE}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Link to download Thonny Python IDE for beginners} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}https://thonny.org/} \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Thonny is a popular Python Integrated Development Environment (IDE) that is designed for beginners and students learning to program in Python.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{1.2. Run Thorny Python IDE}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/tinhvy_1676778391_thorny_get_started.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Thonny comes with Python 3.10 built in, so just one simple installer is needed and you're ready to learn programming. (You can also use a separate Python installation, if necessary.) The initial user interface is stripped of all features that may distract beginners.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{1.3. Python Programming Keywords}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{False} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{None} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{True} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{and} \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{as} \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{assert} \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{except} \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{In Python, All keywords are case sensitive. All the keywords except True, False and None are in lowercase and they must be written as it is.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{1.4. Create a program to test Keywords}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\textgreater{}\textgreater{}\textgreater{} import keyword \newline \textgreater{}\textgreater{}\textgreater{} \seqsplit{keyword.iskeyword("tutsmake.com")} \newline False \newline \textgreater{}\textgreater{}\textgreater{} keyword.iskeyword("try") \newline True \newline \textgreater{}\textgreater{}\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{1.5. Python Programming identifiers}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Identifier rules of Python} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{Rule 1:}}} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Use either a lowercase (A to Z) or an uppercase (A to Z) sequence of letters. However, you can also add digits (0 to 9) or an underscore (\_) while writing identity in python.} \tn % Row Count 6 (+ 5) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}For example:- Names like myClass, my\_1, and upload\_image\_to\_db are all valid identifiers.} \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{Rule 2:}}} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}You cannot write digit with the start of an identifier. This will assume invalid. But you can write digit with the end of the identifier.} \tn % Row Count 12 (+ 4) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}For Example:- If you write identifier like 1variable, it is invalid, but variable1 is perfectly fine.} \tn % Row Count 15 (+ 3) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{Rule 3:}}} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Python Programming Reserved Keywords cannot be used as identifiers. Like del, global, not, with, as, if, etc.} \tn % Row Count 19 (+ 4) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\bf{Rule 4:}}} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Also, you can not use special character as an identifier in python programming like '.', '!', '@', '\#', '\$', '\%' , etc.} \tn % Row Count 24 (+ 5) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{Rule 5:}}} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}The identifier can be of any length.} \tn % Row Count 26 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{In the Python programming language, identifiers are user-defined names. Which represents functions, classes, variables, and any other objects in the code. It helps to distinguish one identity from another.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{1.6. Create a program to test identifier}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\textgreater{}\textgreater{}\textgreater{} 'jonh'.isidentifier() \newline True \newline \textgreater{}\textgreater{}\textgreater{} '1hello'.isidentifier() \newline False \newline \textgreater{}\textgreater{}\textgreater{} \seqsplit{'tutsmake.com'.isidentifier()} \newline False \newline \textgreater{}\textgreater{}\textgreater{} \seqsplit{'tutsmake\_com'.isidentifier()} \newline True} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{1.7. Python Statement}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\bf{Simple Assignment Statement}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Syntax:} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`variable = expression`} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Example:} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`lang = "Learn Python"`} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{Multi-line statement}}} \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Use a new line character to break the statement line} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`x = 5 + 4 + 2 + \textbackslash{} \{\{nl\}\} 1 + 6 + 4 + \textbackslash{}\{\{nl\}\} 9 + 7 + 8`\{\{nl\}\}} \tn % Row Count 10 (+ 4) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Use parentheses ( ), brackets {[} {]} and braces \{ \}.} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`x = (5 + 4 + 2 +\{\{nl\}\} 1 + 6 + 4 +\{\{nl\}\} 9 + 7 + 8)`\{\{nl\}\}} \tn % Row Count 13 (+ 3) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`colors = {[}'red',\{\{nl\}\} 'blue',\{\{nl\}\} 'green'{]}`\{\{nl\}\}} \tn % Row Count 15 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Multiple line statements in signle line.} \tn % Row Count 16 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Use semicolons} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`a = 1; b = 2; c = 3`} \tn % Row Count 18 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{In python programming, A statement is a logical instruction. Which can read and execute by Python interpreter. In Python, it could be an expression or an assignment statement.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.8 cm} x{7.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{1.8. Python Indentation}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{{\bf{Python uses indentation}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{8.4cm}}{A code block starts with indentation and ends with the first unindented line. And a code block that represents the body of a function, loop, etc. For example:} \tn % Row Count 5 (+ 4) % Row 2 \SetRowColor{LightBackground} & `for i in range(1,9):\{\{nl\}\} print(i)\{\{nl\}\} if i == 5:\{\{nl\}\} break`\{\{nl\}\} \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{8.4cm}}{{\bf{Python Comments}}} \tn % Row Count 9 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Single line comment} \tn % Row Count 10 (+ 1) % Row 5 \SetRowColor{white} & `\#This is hello world by tutsmake.com\{\{nl\}\} print('Hello world')` \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Multi line comment} \tn % Row Count 13 (+ 1) % Row 7 \SetRowColor{white} & `\#This is hello world program\{\{nl\}\} \#by tutsmake.com\{\{nl \#hello\{\{nl print('Hello world'` \tn % Row Count 16 (+ 3) % Row 8 \SetRowColor{LightBackground} & `"""This is also a\{\{nl\}\} multi line\{\{nl\}\} comments"""\{\{nl\}\} print('Hello world')` \tn % Row Count 19 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.8 cm} x{7.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{1.9. Docstring in Python}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Docstring in Python} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} & `def myFunc(no):\{\{nl\}\} """Function to 10x the value"""\{\{nl\}\} return 10*no` \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{access the code above} \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} & `\textgreater{}\textgreater{}\textgreater{} \seqsplit{print(myFunc.\_\_doc\_\_)`} \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{1.10. Python Variable and Type}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\bf{Rules for creating a variable in python}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Rule 1:} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}A variable name must begin with a letter or the underscore character} \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Rule 2:} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}A variable name cannot begin with a number} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Rule 3:} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}The python variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and \_ )} \tn % Row Count 10 (+ 4) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Rule 4:} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}A Variable names are case-sensitive Like name, Name and NAME are three different variables} \tn % Row Count 13 (+ 3) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{Python declare/create variable}}} \tn % Row Count 14 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Here first we will create/declare a variable. And also assign value to it.} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`x = 10\{\{nl\}\}print("My fav no is " + x)`} \tn % Row Count 17 (+ 3) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{Change variable value in python}}} \tn % Row Count 18 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{We will create a variable and change the value of this variable at runtime.} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`x = 10\{\{nl\}\}print("My fav no is " + x)\{\{nl\}\}x = 15\{\{nl\}\}print("My fav no is " + x) `} \tn % Row Count 22 (+ 4) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{Assigning a single value to multiple variables}}} \tn % Row Count 23 (+ 1) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Python allows to assign a single value to several variables simultaneously.} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`x = y = z = 10\{\{nl\}\}print(x)\{\{nl\}\}print(y)\{\{nl\}\}print(z)`} \tn % Row Count 27 (+ 4) % Row 11 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{Assigning a different values to multiple variables}}} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`x, y, z = 5, "string", 99 \{\{nl\}\}print(x) \{\{nl\}\}print(y) \{\{nl\}\}print(z)`} \tn % Row Count 31 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{1.10. Python Variable and Type (cont)}} \tn % Row 12 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\bf{Types of variables}}} \tn % Row Count 1 (+ 1) % Row 13 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Local Variable} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Which variables are made inside the function. They are called local variables. Local variables can be used only inside the function. For example:} \tn % Row Count 6 (+ 5) % Row 14 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}` def valfun():\{\{nl\}\} x = "great"\{\{nl\}\} print("Python is " + x)\{\{nl\}\} valfun()`} \tn % Row Count 8 (+ 2) % Row 15 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Global Variable} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Which variables are made outside the function. They are called global variables. Global variables can be used both inside and outside the function. For example:} \tn % Row Count 13 (+ 5) % Row 16 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}` x = "great"\{\{nl\}\} def valfun():\{\{nl\}\} print("Python is " + x)\{\{nl\}\} valfun() `} \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{1.11. Data Types in Python}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\bf{Numbers Data Type}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Integer, floating-point numbers, and complex numbers under the category of Python numbers. Those you define as int, float and complex classes. For example:} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}` a = 10\{\{nl\}\} print(a, "is of type", type(a))\{\{nl\}\}\{\{nl\}\} a = 50.0\{\{nl\}\} print(a, "is of type", type(a))\{\{nl\}\}\{\{nl\}\} a = 11+2j\{\{nl\}\} print(a, "is complex number?", isinstance(11+2j,complex)) `} \tn % Row Count 10 (+ 9) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Output of the above program is following:} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}` 10 is of type \textless{}class 'int'\textgreater{}\{\{nl\}\} 50.0 is of type \textless{}class 'float'\textgreater{}\{\{nl\}\} (11+2j) is complex number? True `} \tn % Row Count 14 (+ 4) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{List Data Type}}} \tn % Row Count 15 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{list data types hold different types of data. it does not need to be of the same type. The items stored in the list are separated with a comma (,) and enclosed within square brackets {[}{]}.} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}` a = {[}10, 5.5, 'python'{]} \{\{nl\}\} print(a) \{\{nl\}\} a = {[}5,10,15,20,25,30,35,40{]} \{\{nl\}\} \# a{[}2{]} = 15 \{\{nl\}\} print("a{[}2{]} = ", a{[}2{]}) \{\{nl\}\} \# a{[}0:3{]} = {[}5, 10, 15{]} \{\{nl\}\} print("a{[}0:3{]} = ", a{[}0:3{]}) \{\{nl\}\} \# a{[}5:{]} = {[}30, 35, 40{]} \{\{nl\}\} print("a{[}5:{]} = ", a{[}5:{]}) `} \tn % Row Count 25 (+ 10) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{The output of the above program is following:} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}` {[}10, 5.5, 'python'{]}\{\{nl\}\} a{[}2{]} = 15\{\{nl\}\} a{[}0:3{]} = {[}5, 10, 15{]}\{\{nl\}\} a{[}5:{]} = {[}30, 35, 40{]} `} \tn % Row Count 29 (+ 4) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\bf{Tuple Data Type}}} \tn % Row Count 30 (+ 1) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{1.11. Data Types in Python (cont)}} \tn % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{A tuples data type is alike to list data type. But it is only one difference, once tuples created can not be changed/modify. \{\{nl\}\}Tuples contain the collection of the items of different data types alike list data type. The items of the tuple are separated with a comma (,) and enclosed in parentheses ().} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}` a = (8,'python', 1+2j) \{\{nl\}\} \# a{[}1{]} = 'program' \{\{nl\}\} print("a{[}1{]} = ", a{[}1{]}) \{\{nl\}\} \# a{[}0:3{]} = (5, 'program', (1+3j)) \{\{nl\}\} print("a{[}0:3{]} = ", a{[}0:3{]}) `} \tn % Row Count 11 (+ 11) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Output of the above code is following:} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}` a{[}1{]} = python \{\{nl\}\} a{[}0:3{]} = (8, 'python', (1+2j)) `} \tn % Row Count 14 (+ 3) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{Strings Data Type}}} \tn % Row Count 15 (+ 1) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{A string is a sequence of characters in Python. In python, Strings are either enclosed with single quotes, double, and triple quotes.} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}` string = 'Hello world!' \{\{nl\}\} \# string{[}1{]} = 'e' \{\{nl\}\} print("string{[}1{]} = ", string{[}1{]}) \{\{nl\}\} mString = """Hello world! \{\{nl\}\} this is multi \{\{nl\}\} line string example""" \{\{nl\}\} print(mString) `} \tn % Row Count 23 (+ 8) % Row 11 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Output of the above program is the following:} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}` string{[}1{]} = e \{\{nl\}\} Hello world! \{\{nl\}\} this is multi \{\{nl\}\} line string example `} \tn % Row Count 27 (+ 4) % Row 12 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\bf{Set Data Type}}} \tn % Row Count 28 (+ 1) % Row 13 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Set data types hold unordered collection of unique items. The items stored in the set data types are separated with a comma (,) and enclosed within square brackets \{ \}.} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}` abc = \{5,2,3,1,4\} \{\{nl\}\} \# printing set variable \{\{nl\}\} print("abc = ", abc) \{\{nl\}\} \# data type of variable a \{\{nl\}\} print(type(abc)) `} \tn % Row Count 35 (+ 7) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{1.11. Data Types in Python (cont)}} \tn % Row 14 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Output of the above program is following:} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}` abc = \{1, 2, 3, 4, 5\}\{\{nl\}\} \textless{}class 'set'\textgreater{} `} \tn % Row Count 2 (+ 2) % Row 15 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{Dictionary Data Type}}} \tn % Row Count 3 (+ 1) % Row 16 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Dictionary data types is held data in key and value pairs. Note:- A dictionary data type does not allow duplicate keys in collection. But the values ​​can be duplicate. For example:} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}` dict = \{1:"john","lastname":"smith", "age":25\} \{\{nl\}\} \# prints the value where key value is 1 \{\{nl\}\} print(dict{[}1{]}) \{\{nl\}\} \# prints the value where key value is "lastname" \{\{nl\}\} print(dict{[}"lastname"{]}) \{\{nl\}\} \# prints the value where key value is "age" \{\{nl\}\} print(dict{[}"age"{]}) `} \tn % Row Count 14 (+ 11) % Row 17 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Output of the above program is following:} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`john smith 25`} \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{TOPIC: FLOW CONTROL}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{TOPIC: FUNCTIONS}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{TOPIC: DATATYPES}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{TOPIC: FILE HANDLING}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{- File Handling Operation \newline - Python open and close \newline - Python Read and Write \newline - Python File Delete} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{TOPIC: Python built-in Methods}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{- Math Functions \newline - Math Module Functions \newline - String Methods \newline - List Methods \newline - Dictionary Methods \newline - Set Methods} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}