\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{Jean-Pierre Mouret (jpmou)} \pdfinfo{ /Title (ef-informatik-mou.pdf) /Creator (Cheatography) /Author (Jean-Pierre Mouret (jpmou)) /Subject (EF Informatik (MOU) 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}{0D6321} \definecolor{LightBackground}{HTML}{F7FAF8} \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{EF Informatik (MOU) Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Jean-Pierre Mouret (jpmou)} via \textcolor{DarkBackground}{\uline{cheatography.com/163229/cs/34189/}}} \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}Jean-Pierre Mouret (jpmou) \\ \uline{cheatography.com/jpmou} \\ \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 20th September, 2022.\\ 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{1.9 cm} x{3.268 cm} x{2.432 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Datentypen}} \tn % Row 0 \SetRowColor{LightBackground} \{\{width=23\}\}{\emph{Numerisch}} & \{\{width=35\}\} & \{\{width=42\}\} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\bf{`int`}} & ganze Zahlen & `-3214` , `42` \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{`float`}} & Gleitkommazahlen & `3.141` , `-5.76e-2` , `2E02` \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} {\bf{`bool`}} & boolesche Werte & `True` , `False` \tn % Row Count 10 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{`complex`}} & komplexe Zahlen & `3.4 + 4e2j` , `3J + 7` \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{3}{x{8.4cm}}{{\emph{Datenstrukturen}}} \tn % Row Count 13 (+ 1) % Row 6 \SetRowColor{LightBackground} {\bf{`string`}} & Zeichenkette & "grün" , 'Blau' \tn % Row Count 15 (+ 2) % Row 7 \SetRowColor{white} {\bf{`list`}} & allgemeine Liste (Stack) & {[}value, …{]} \tn % Row Count 17 (+ 2) % Row 8 \SetRowColor{LightBackground} {\bf{`tuple`}} & {\bf{unver{\"a}nderbare}} Liste & (value, …)\textasciicircum{}1\textasciicircum{} \tn % Row Count 19 (+ 2) % Row 9 \SetRowColor{white} {\bf{`set`}} & ungeordnete und {\bf{nicht}} indizierte Liste & \{value, …\} \tn % Row Count 22 (+ 3) % Row 10 \SetRowColor{LightBackground} {\bf{`dictionary`}} & Liste mit {\bf{key}} als Index & \{key:value, …\}\textasciicircum{}2\textasciicircum{} \tn % Row Count 24 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \SetRowColor{LightBackground} \mymulticolumn{3}{x{8.4cm}}{\textasciicircum{}1\textasciicircum{} Klammern optional \newline \textasciicircum{}2\textasciicircum{} key muss {\bf{eindeutig}} sein} \tn \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.432 cm} x{1.824 cm} x{3.344 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Typunwandlung}} \tn % Row 0 \SetRowColor{LightBackground} \{\{width=15\}\}`{\bf{int}}(a)` & `a` → {\bf{int}} & `x = int(3.0) , y = int("4")` \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `{\bf{float}}(a)` & `a` → {\bf{float}} & `x = float(2) , y = float("42")` \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `{\bf{str}}(a)` & `a` → {\bf{string}} & `x = str(2) , y = str(4.2)` \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{3}{x{8.4cm}}{} \tn % Row Count 6 (+ 0) % Row 4 \SetRowColor{LightBackground} `{\bf{set}}(a)` & `a` → {\bf{set}} & `x = set({[}1,2,3{]}) , y = set()` \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} `{\bf{list}}(a)` & `a` → {\bf{list}} & `x = list(('a', 'b', 'c'))` \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \SetRowColor{LightBackground} \mymulticolumn{3}{x{8.4cm}}{Die Funktion {\bf{`input()`}} gibt immer einen {\bf{String}} zurück. \newline Soll die Eingabe z.B. einem int zugewiesen werden: \newline {\bf{`x = int(input())`}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.296 cm} x{2.952 cm} x{1.152 cm} x{1.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{8.4cm}}{\bf\textcolor{white}{Arithmetische Operatoren}} \tn % Row 0 \SetRowColor{LightBackground} `x + y` & Addition & `x - y` & \seqsplit{Subtraktion} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `x * y` & Multiplikation & `x / y` & Division \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `x // y` & Division ohne Rest & `x \% y` & Modulo \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} `x ** y` & Potenz x\textasciicircum{}y\textasciicircum{} & & \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}----} \SetRowColor{LightBackground} \mymulticolumn{4}{x{8.4cm}}{Zuweisungskurzbefehle: {\bf{x Operator= y}} \newline Bsp: {\bf{x += 5}} entspricht {\bf{x = x + 5}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.296 cm} x{1.296 cm} x{1.44 cm} x{3.168 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{8.4cm}}{\bf\textcolor{white}{Vergleichsoperatoren}} \tn % Row 0 \SetRowColor{LightBackground} `x \textless{} y` & \seqsplit{kleiner} & `x \textless{}= y` & kleiner oder gleich \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `x \textgreater{} y` & gr{\"o}sser & `x \textgreater{}= y` & gr{\"o}sser oder gleich \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `x == y` & gleich & `x != y` & ungleich \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.216 cm} x{2.356 cm} x{4.028 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Logische Operatoren}} \tn % Row 0 \SetRowColor{LightBackground} `x and y` & x {\bf{und}} y wahr & `(3 \textgreater{} 2) and (2 \textless{} 4) \# False` \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `x or y` & x {\bf{oder}} y wahr & `(3 \textgreater{} 2) or (2 \textless{} 4) \# True` \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `not x` & x {\bf{nicht}} wahr & `(3 \textgreater{} 2) \# False` \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.368 cm} x{2.356 cm} x{3.876 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Mitgliedsoperationen}} \tn % Row 0 \SetRowColor{LightBackground} `x in y` & x Element von y & `5 in (1,2,3,4,5) \# True` \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `x not in y` & x kein Element von y & `5 not in (1,2,3,4,5) \# False` \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Bedingte Ausführung}} \tn % Row 0 \SetRowColor{LightBackground} \{\{width=40\}\}`{\bf{îf}} {\emph{Bedingung}}:`\{\{nl\}\}~~~~~~{\emph{`Anweisung(en)`}} & Anweisungen werden ausgeführt, falls {\bf{Bedingung}} wahr und if-Konstrukt wird verlassen \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} `{\bf{elif}} {\emph{Bedingung}}:`\{\{nl\}\}~~~~~~{\emph{`Anweisung(en)`}} & (optional, mehrere `elif`-Bl{\"o}cke m{\"o}glich) Anweisungen werden ausgeführt, falls {\bf{Bedingung}} wahr und if-Kostrukt wird verlassen \tn % Row Count 12 (+ 7) % Row 2 \SetRowColor{LightBackground} `{\bf{else}}:`\{\{nl\}\}~~~~~~{\emph{`Anweisung(en)`}} & (optional) Anweisungen werden ausgeführt, falls keine der Bedingungen wahr waren \tn % Row Count 17 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Schleifen}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`{\bf{while}} Bedingung:`\{\{nl\}\}~~~~~~{\emph{`Anweisung(en)`}}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 2 (+ 0) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`{\bf{for}} i {\bf{in}} range({\emph{start,end{[},step{]}):`\textasciicircum{}1\textasciicircum{}\{\{nl\}\}~~~~~~}}`Anweisung(en)`*} \tn % Row Count 5 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`{\bf{for}} index {\bf{in}} {\emph{Datenstruktur}}:`\{\{nl\}\}~~~~~~{\emph{`Anweisung(en)`}}} \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 7 (+ 0) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`{\bf{for}} key {\bf{in}} sorted(dictonary):`\{\{nl\}\}~~~~~~{\emph{`Anweisung(en)`}}} \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\textasciicircum{}1\textasciicircum{} Schleife geht von {\bf{start}} bis {\bf{end-1}} \newline `{\bf{break}}` beendet die Schleife, `{\bf{continue}}` den aktuellen Durchlauf} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.368 cm} x{2.088 cm} x{1.584 cm} x{2.16 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{8.4cm}}{\bf\textcolor{white}{Indizes und Teilsequenzen (string, list, tuple)}} \tn % Row 0 \SetRowColor{LightBackground} len(a) & 6 & & \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} a{[}0{]} & 0 & a{[}5{]} & 5 \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} a{[}-1{]} & 5 & a{[}-2{]} & 4 \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} a{[}1:{]} & {[}1,2,3,4,5{]} & a{[}:5{]} & {[}0,1,2,3,4{]} \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} a{[}:-2{]} & {[}0,1,2,3{]} & a{[}1:3{]} & {[}1,2{]} \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} a{[}1:-1{]} & {[}1,2,3,4{]} & b = a{[}:{]} & klonen \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}----} \SetRowColor{LightBackground} \mymulticolumn{4}{x{8.4cm}}{Indizes und Teilsequenzen für a = {[}0,1,2,3,4,5{]}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.72 cm} x{5.28 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{String-, List-, Tuple-Operationen}} \tn % Row 0 \SetRowColor{LightBackground} `len(s)` & L{\"a}nge von s \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `sorted(s)` & Sortierte Kopie von s \tn % Row Count 2 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.28 cm} x{4.72 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{String-Operationen}} \tn % Row 0 \SetRowColor{LightBackground} `str.lower()` & umwandelin in Kleinbuchstaben \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `str.upper()` & umwandeln in Grossbuchstaben \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{`str.replace(alt}, neu)` & {\emph{alt}} durch {\emph{neu}} ersetzen \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} `str.split()` & erzeugt Liste aus den Sub-Strings \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.04 cm} x{4.96 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{List-Operationen}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{`lst.append(e)`} & h{\"a}ngt e an \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `lst.insert(i, e)` & fügt e for 1-tem Element ein \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} `lst.pop(i)` & entfernt i-tes Element \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \seqsplit{`lst.remove(e)`} & entfernt 1. Element mit Wert e \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} `del lst{[}i{]}` & entfernt i-tes Element \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}