\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{Freebeater} \pdfinfo{ /Title (python-pcep.pdf) /Creator (Cheatography) /Author (Freebeater) /Subject (Python PCEP 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}{2B5B84} \definecolor{LightBackground}{HTML}{F1F4F7} \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 PCEP Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Freebeater} via \textcolor{DarkBackground}{\uline{cheatography.com/177378/cs/37029/}}} \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}Freebeater \\ \uline{cheatography.com/freebeater} \\ \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 12th 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*}{3} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{PE1 Module 2}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{PE1 Module 2 - Python Data Types, Variables, Operators, and Basic I/O operations}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.4839 cm} x{1.4931 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{M2 S1 - The "Hello, World!" Program}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Code}} & {\bf{Output}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} print("Hello, world!") & Hello, world! \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} print("My name is", "Python") & My name is Python \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} print("Hello", "World", sep="*", end="!*") & Hello,*World!* \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{M2 S2 - Python Literals}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{DataType}} & {\bf{Examples}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Integer & -256, 256 \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} Float & -256.2, 1.123e-10 \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} String & "Hello", 'Hello World' \tn % Row Count 5 (+ 2) % Row 4 \SetRowColor{LightBackground} Boolean Values & True, False \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} {\bf{Encodage}} & {\bf{Output de 23 en décimal}} \tn % Row Count 8 (+ 2) % Row 6 \SetRowColor{LightBackground} décimal & print(23) \tn % Row Count 9 (+ 1) % Row 7 \SetRowColor{white} octal & print(0o27) \tn % Row Count 10 (+ 1) % Row 8 \SetRowColor{LightBackground} héxadécimal & print(0x17) \tn % Row Count 11 (+ 1) % Row 9 \SetRowColor{white} {\bf{Exemple Escape character}} & {\bf{Output}} \tn % Row Count 13 (+ 2) % Row 10 \SetRowColor{LightBackground} print("C'est \textbackslash{}"Jean\textbackslash{}"") & C'est "Jean" \tn % Row Count 15 (+ 2) % Row 11 \SetRowColor{white} print('He\textbackslash{}'s "Jean"') & He's "Jean" \tn % Row Count 17 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.05965 cm} x{1.78503 cm} p{0.73232 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{M2 S3 - Operators data maniputalion tools}} \tn % Row 0 \SetRowColor{LightBackground} Operations & Exemples & \seqsplit{Output} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Addition & print(2 + 2) & 4 \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} Soustration & print(5 - 2) & 3 \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} Multiplication & print(2 * 3) & 6 \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} Division & print(6.3 / 3) & 2.1 \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} Division entière & print(6.3 // 3) & 2 \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} Modulo & print(9 \% 6) & 3 \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} Exposant & print(2 ** 3) & 8 \tn % Row Count 8 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.83689 cm} x{2.14011 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{M2 S4 - Variables}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Type of value to assign}} & {\bf{Exemples}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} integer & var = 1 \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} string & name = "UwU" \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} {\bf{Expression}} & {\bf{Shorcut operator}} \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} i = i + 2 * j & i += 2 * j \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} var = var / 2 & var /= 2 \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} rem = rem \% 10 & rem \%= 10 \tn % Row Count 9 (+ 1) % Row 7 \SetRowColor{white} j = j - (i + var + rem) & j -= (i + var + rem) \tn % Row Count 11 (+ 2) % Row 8 \SetRowColor{LightBackground} x = x ** 2 & x **= 2 \tn % Row Count 12 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.83689 cm} x{2.14011 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{M2 S5 - Comments}} \tn % Row 0 \SetRowColor{LightBackground} Commentaires & \# \textless{}texte\textgreater{} \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{M2 S6 - Interaction with the user}} \tn % Row 0 \SetRowColor{LightBackground} input("Tell me anything") & Inviter l'utilisateur à entrer quelque chose \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \seqsplit{float(input("Tell} me anything")) & Caste l'entrée de l'utilisateur (qui est un string) en float \tn % Row Count 6 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{PE1: Module 3}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{PE1: Module 3 - Boolean Values, Conditional Execution, Loops, Lists and List Processing, Logical and Bitwise Operations}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.68758 cm} x{2.28942 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{M3 S1 - Making decisions in Python}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Comparaison}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Egalité & == \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} Inégalité & != \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} Plus grand que & \textgreater{} \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} Plus petit que & \textless{} \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} Plus grand ou égal à & \textgreater{}= \tn % Row Count 7 (+ 2) % Row 6 \SetRowColor{LightBackground} Plus petit ou égal à & \textless{}= \tn % Row Count 9 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Condition d'exécution}}} \tn % Row Count 10 (+ 1) % Row 8 \SetRowColor{LightBackground} Si & `if \textless{}condition\textgreater{}:` \tn % Row Count 11 (+ 1) % Row 9 \SetRowColor{white} Sinon si & `elif \textless{}condition\textgreater{}:` \tn % Row Count 13 (+ 2) % Row 10 \SetRowColor{LightBackground} Sinon & `else \textless{}condition\textgreater{}:` \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{M3 S2 - Looping your code with while}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Boucles}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Tant que & `while \textless{}condition\textgreater{}:` \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} Infini tant que & `while True:` \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} Pour i de 0 à 100 & `for i in range(100):` \tn % Row Count 5 (+ 2) % Row 4 \SetRowColor{LightBackground} Pour i de 2 à 7 \{\{nl\}\} en incrémentant par 3 & `for i in range(2, 8, 3):`\{\{nl\}\} range(start, stop, step) \tn % Row Count 8 (+ 3) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Instructions dans la boucle}}} \tn % Row Count 9 (+ 1) % Row 6 \SetRowColor{LightBackground} Sortir de la boucle & break \tn % Row Count 10 (+ 1) % Row 7 \SetRowColor{white} Passer directement à la \{\{nl\}\} prochaine itération de la \{\{nl\}\}boucle & continue \tn % Row Count 14 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{M3 S3 - Logic and bit operations in Python}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Operateurs logiques}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Et & and \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} Ou & or \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} negation & not \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} exemple & not (p and q) == (not p) or (not q) \tn % Row Count 6 (+ 2) % Row 5 \SetRowColor{white} {\bf{Operateurs binaires}} & {\bf{A peut être 0 ou 1 \{\{nl\}\} B peut être 0 ou 1}} \tn % Row Count 9 (+ 3) % Row 6 \SetRowColor{LightBackground} Disjonction (or) binaire & | \{\{nl\}\} A | B \tn % Row Count 11 (+ 2) % Row 7 \SetRowColor{white} Conjonction (and) binaire & \& \{\{nl\}\} A \& B \tn % Row Count 13 (+ 2) % Row 8 \SetRowColor{LightBackground} Ou exclusif (xor) binaire & \textasciicircum{} \{\{nl\}\} A \textasciicircum{} B \tn % Row Count 15 (+ 2) % Row 9 \SetRowColor{white} Negation (not) binaire & \textasciitilde{} \{\{nl\}\} \textasciitilde{}A \tn % Row Count 17 (+ 2) % Row 10 \SetRowColor{LightBackground} {\bf{Operateurs de décalage (shift) \{\{nl\}\} Pour var = 17}} & Output \tn % Row Count 20 (+ 3) % Row 11 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Décaler vers la droite revient à diviser par deux} \tn % Row Count 22 (+ 2) % Row 12 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Décaler vers la gauche revient à multiplier par deux} \tn % Row Count 24 (+ 2) % Row 13 \SetRowColor{white} var\_right = var \textgreater{}\textgreater{} 1 & print(var\_right) \{\{nl\}\} 8 \tn % Row Count 26 (+ 2) % Row 14 \SetRowColor{LightBackground} var\_left = var \textless{}\textless{} 2 & print(var\_left) \{\{nl\}\} 68 \tn % Row Count 28 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{M3 S4 - Lists}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Initialisation et indexation}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Initialisation d'une liste & numbers = {[}10, 5, 2, 1{]} \{\{nl\}\} print(numbers) \{\{nl\}\} Output : {[}10, 5, 2, 1{]} \tn % Row Count 5 (+ 4) % Row 2 \SetRowColor{LightBackground} Modification d'un élément & numbers{[}1{]} = 3 \{\{nl\}\} print(numbers) \{\{nl\}\} Output : {[}10, 3, 2, 1{]} \tn % Row Count 9 (+ 4) % Row 3 \SetRowColor{white} Accès à un élément \{\{nl\}\} négativement & print(numbers{[}-2{]}) \{\{nl\}\} Output : 2 \tn % Row Count 12 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Différences}}} \tn % Row Count 13 (+ 1) % Row 5 \SetRowColor{white} Fonctions & result = function(arg) \tn % Row Count 15 (+ 2) % Row 6 \SetRowColor{LightBackground} Méthodes & result = data.method(arg) \tn % Row Count 17 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Fonctions}}} \tn % Row Count 18 (+ 1) % Row 8 \SetRowColor{LightBackground} Fonction {\bf{len}} \{\{nl\}\} Calculer la taille de la liste & print(len(numbers)) \{\{nl\}\} Output : 4 \tn % Row Count 21 (+ 3) % Row 9 \SetRowColor{white} Fonction {\bf{del}} \{\{nl\}\} Supprimer un élément \{\{nl\}\} de la liste. & del numbers{[}0{]} \{\{nl\}\} print(numbers) \{\{nl\}\} Output : {[}3, 2, 1{]} \tn % Row Count 25 (+ 4) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Méthodes}}} \tn % Row Count 26 (+ 1) % Row 11 \SetRowColor{white} Methode {\bf{append}} \{\{nl\}\} Ajouter un élément à la fin \{\{nl\}\} de la liste & numbers.append(4) \{\{nl\}\} print(numbers) \{\{nl\}\} Output : {[}3, 2, 1, 4{]} \tn % Row Count 30 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{M3 S4 - Lists (cont)}} \tn % Row 12 \SetRowColor{LightBackground} Méthode {\bf{insert}} \{\{nl\}\} Ajouter un élément sur un emplacement défini & numbers.insert(0,5) \{\{nl\}\} print(numbers) \{\{nl\}\} Output : {[}5,3,2,1,4{]} \tn % Row Count 4 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.94103 cm} x{3.03597 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{M3 S5 -Sorting simple lists}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Trier une liste avec la méthode sort}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Initialisation de la liste & my\_list = {[}8, 10, 6, 2, 4{]} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} Affichage de la liste & print(my\_list) \{\{nl\}\} Output : {[}8, 10, 6, 2, 4{]} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} Application de la fonction & my\_list.sort() \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} Affichage de la liste & print(my\_list) \{\{nl\}\} Output : {[}2, 4, 6, 8, 10{]} \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Il faut voir le {\bf{tri à bulle}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{M3 S6 - Operations on lists}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Slices :}} \{\{nl\}\} Afficher à une partie de la liste & my\_list{[}start:end{]} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Afficher du 1er élément au 3ème & print(my\_list{[}:3{]}) \{\{nl\}\} Output : {[}10,8,6{]} \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} Afficher du 3ème élément au dernier & print(my\_list{[}2:{]}) \{\{nl\}\} Output : {[}6,4,2{]} \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} Afficher du 2ème élément au 3eme & print(my\_list{[}1:3{]}) \{\{nl\}\} Output : {[}8,6{]} \tn % Row Count 12 (+ 3) % Row 4 \SetRowColor{LightBackground} Supprimer des éléments 2 à 3 & del my\_list{[}1:3{]} \{\{nl\}\} print(my\_list) \{\{nl\}\} Output : {[}10,4,2{]} \tn % Row Count 16 (+ 4) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Opérateurs {\bf{in}} et {\bf{not}}} \tn % Row Count 17 (+ 1) % Row 6 \SetRowColor{LightBackground} in \{\{nl\}\} Vérifier si un élément est présent dans la liste & elem in my\_list \tn % Row Count 21 (+ 4) % Row 7 \SetRowColor{white} not in \{\{nl\}\} Vérifier si un élément n'est pas présent dans la liste & elem not in my\_list \tn % Row Count 25 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{On utilise la liste {[}10, 8, 6, 4, 2{]}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{M3 S7 - Lists in advanced applications}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Créer une ligne d'échec de pion blanc en une ligne de code} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{row = {[}WHITE\_PAWN for i in range(8){]}} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Créer un plateau d'échec avec une liste à deux dimensions en une ligne de code} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{board = {[}{[}EMPTY for i in range(8){]} for j in range(8){]}} \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}