\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{Niels R{\"o}hrdanz (Niels132)}
\pdfinfo{
  /Title (python-3.pdf)
  /Creator (Cheatography)
  /Author (Niels R{\"o}hrdanz (Niels132))
  /Subject (Python 3 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}{A3A3A3}
\definecolor{LightBackground}{HTML}{F3F3F3}
\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 3 Cheat Sheet}}}} \\
    \normalsize{by \textcolor{DarkBackground}{Niels R{\"o}hrdanz (Niels132)} via \textcolor{DarkBackground}{\uline{cheatography.com/44142/cs/13079/}}}
\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}Niels R{\"o}hrdanz (Niels132) \\
  \uline{cheatography.com/niels132} \\
  \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 23rd November, 2020.\\
   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{tabularx}{17.67cm}{x{3.0366 cm} x{3.0366 cm} x{10.7968 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{Basisdatentypen}}  \tn
% Row 0
\SetRowColor{LightBackground}
\seqsplit{Integer} & int() & 2,0,3,-2 \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
Float & \seqsplit{float()} & 2.307, 0.0, -2.34567 \tn 
% Row Count 2 (+ 1)
% Row 2
\SetRowColor{LightBackground}
String & str() & 'Hallo ich bin ein String' \tn 
% Row Count 4 (+ 2)
% Row 3
\SetRowColor{white}
\seqsplit{Boolean} & bool() & True, False \tn 
% Row Count 5 (+ 1)
\hhline{>{\arrayrulecolor{DarkBackground}}---}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{p{3.0366 cm} p{3.0366 cm} x{10.7968 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{numerische Operationen}}  \tn
% Row 0
\SetRowColor{LightBackground}
5+1 & \textgreater{}\textgreater{}6 & Addition \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
5-1 & \textgreater{}\textgreater{}4 & Subtraktion \tn 
% Row Count 2 (+ 1)
% Row 2
\SetRowColor{LightBackground}
3/5 & \textgreater{}\textgreater{}.6 & Division \tn 
% Row Count 3 (+ 1)
% Row 3
\SetRowColor{white}
3//5 & \textgreater{}\textgreater{}0 & Floor Division \tn 
% Row Count 4 (+ 1)
% Row 4
\SetRowColor{LightBackground}
3\%5 & \textgreater{}\textgreater{}3 & Modulo \tn 
% Row Count 5 (+ 1)
% Row 5
\SetRowColor{white}
3*5 & \textgreater{}\textgreater{}15 & Multiplikation \tn 
% Row Count 6 (+ 1)
% Row 6
\SetRowColor{LightBackground}
3**3 & \textgreater{}\textgreater{}27 & Potenz \tn 
% Row Count 7 (+ 1)
\hhline{>{\arrayrulecolor{DarkBackground}}---}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{x{3.8801 cm} x{2.6992 cm} x{10.2907 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{sequentielle Datentypen}}  \tn
% Row 0
\SetRowColor{LightBackground}
Liste & \seqsplit{list()} & {[}1,2,3,5,-6,9{]} \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
Tupel & \seqsplit{tuple()} & (1,2,8) \tn 
% Row Count 3 (+ 2)
% Row 2
\SetRowColor{LightBackground}
\seqsplit{Dictionary} & \seqsplit{dict()} & \{'Hallo':'hello','Fünf':5\} \tn 
% Row Count 5 (+ 2)
% Row 3
\SetRowColor{white}
String & str() & 'Hallo ich bin ein String' \tn 
% Row Count 7 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}---}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{x{9.8439 cm} p{7.4261 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Überprüfen/{\"a}ndern des Datentypes}}  \tn
% Row 0
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{x=5} \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
type(x) & \textgreater{}\textgreater{}int \tn 
% Row Count 2 (+ 1)
% Row 2
\SetRowColor{LightBackground}
float(x) & \textgreater{}\textgreater{}5.0 \tn 
% Row Count 3 (+ 1)
% Row 3
\SetRowColor{white}
str(x) & \textgreater{}\textgreater{}'5' \tn 
% Row Count 4 (+ 1)
% Row 4
\SetRowColor{LightBackground}
bool(x) & \textgreater{}\textgreater{}True \tn 
% Row Count 5 (+ 1)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{x{8.2896 cm} x{8.9804 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Operationen auf Strings}}  \tn
% Row 0
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{s='hallo du!'} \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
s.replace('h','H') & \textgreater{}\textgreater{}'Hallo du!' \tn 
% Row Count 2 (+ 1)
% Row 2
\SetRowColor{LightBackground}
substrings=s.split{[}' '{]} & substrings={[}'hallo','du'{]} \tn 
% Row Count 4 (+ 2)
% Row 3
\SetRowColor{white}
s.lower() & \textgreater{}\textgreater{}'hallo du!' \tn 
% Row Count 5 (+ 1)
% Row 4
\SetRowColor{LightBackground}
s.upper() & \textgreater{}\textgreater{}'HALLO DU!' \tn 
% Row Count 6 (+ 1)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{x{3.1293 cm} x{1.647 cm} x{2.6352 cm} x{9.0585 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{4}{x{17.67cm}}{\bf\textcolor{white}{indizierung sequentieller Datentypen}}  \tn
% Row 0
\SetRowColor{LightBackground}
x={[}1,3,5,7,-2{]} & x{[}0{]} & \textgreater{}\textgreater{}1 &  \tn 
% Row Count 2 (+ 2)
% Row 1
\SetRowColor{white}
 & x{[}-1{]} & \textgreater{}\textgreater{}-2 &  \tn 
% Row Count 4 (+ 2)
% Row 2
\SetRowColor{LightBackground}
 & x{[}:{]} & \textgreater{}\textgreater{}1,3,5,7,-2 &  \tn 
% Row Count 6 (+ 2)
% Row 3
\SetRowColor{white}
 & x{[}2:3{]} & \textgreater{}\textgreater{}5 & 2 eingeschlossen, 3 ausgeschlossen \tn 
% Row Count 8 (+ 2)
% Row 4
\SetRowColor{LightBackground}
 & x{[}::2{]} & \textgreater{}\textgreater{}1,5,-2 & jedes 2. Element \tn 
% Row Count 10 (+ 2)
% Row 5
\SetRowColor{white}
 & x{[}::-1{]} & -2,7,5,3,1 & rückw{\"a}rts \tn 
% Row Count 12 (+ 2)
% Row 6
\SetRowColor{LightBackground}
 & x{[}2:{]} & 5,7,-2 & alles ab dem 2. Element \tn 
% Row Count 14 (+ 2)
% Row 7
\SetRowColor{white}
 & x{[}:2{]} & 1,3 & alles bis zum 2. Element (2. Element nicht eingeschlossen) \tn 
% Row Count 17 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}----}
\SetRowColor{LightBackground}
\mymulticolumn{4}{x{17.67cm}}{Die Indizierung sequentieller Datentypen beginnt in Python, wie auch in vielen anderen Programmiersprachen mit der 0. Hier müssen Matlab Nutzer aufpassen!!!}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}----}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{x{7.5988 cm} x{9.6712 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Operationen für sequenzielle Datentypen}}  \tn
% Row 0
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{x={[}2,1,3,4,2{]}} \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
2 in x & \textgreater{}\textgreater{}True \tn 
% Row Count 2 (+ 1)
% Row 2
\SetRowColor{LightBackground}
x.count(2) & \textgreater{}\textgreater{}2 \tn 
% Row Count 3 (+ 1)
% Row 3
\SetRowColor{white}
x.index(2) & \textgreater{}\textgreater{}0 \tn 
% Row Count 4 (+ 1)
% Row 4
\SetRowColor{LightBackground}
x.remove(2) & \textgreater{}\textgreater{}{[}1,3,4{]} \tn 
% Row Count 5 (+ 1)
% Row 5
\SetRowColor{white}
x.sort() & \textgreater{}\textgreater{}{[}1,2,2,3,4{]} \tn 
% Row Count 6 (+ 1)
% Row 6
\SetRowColor{LightBackground}
x.append(1) & \textgreater{}\textgreater{}{[}2,1,3,4,2,1{]} \tn 
% Row Count 7 (+ 1)
% Row 7
\SetRowColor{white}
x+=1 & \textgreater{}\textgreater{}{[}2,1,3,4,2,1{]} \tn 
% Row Count 8 (+ 1)
% Row 8
\SetRowColor{LightBackground}
x*=2 & \textgreater{}\textgreater{}{[}2,1,3,4,2,2,1,3,4,2{]} \tn 
% Row Count 10 (+ 2)
% Row 9
\SetRowColor{white}
x = {[}i*2 for i in x if i != 0 {]} & jedes Element mit zwei multiplizieren au{\ss}er das Element ist 0 \tn 
% Row Count 13 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{x{2.9359 cm} x{14.3341 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Variablen und Zuordnungen}}  \tn
% Row 0
\SetRowColor{LightBackground}
x=1 & x referenziert die Instanz 1 \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
\mymulticolumn{2}{x{17.67cm}}{x,y,z=1,2,3} \tn 
% Row Count 2 (+ 1)
% Row 2
\SetRowColor{LightBackground}
x+=1 & x=x+1 \tn 
% Row Count 3 (+ 1)
% Row 3
\SetRowColor{white}
x-=1 & x=x-1 \tn 
% Row Count 4 (+ 1)
% Row 4
\SetRowColor{LightBackground}
x*=2 & x=x*2 \tn 
% Row Count 5 (+ 1)
% Row 5
\SetRowColor{white}
x/=2 & x=x/2 \tn 
% Row Count 6 (+ 1)
% Row 6
\SetRowColor{LightBackground}
x,y=y,x & Werte tauschen \tn 
% Row Count 8 (+ 2)
% Row 7
\SetRowColor{white}
x=y & x und y referenzieren die gleiche Instanz \tn 
% Row Count 10 (+ 2)
% Row 8
\SetRowColor{LightBackground}
x is y & überprüfen, ob x und y auf die gleiche instanz zeigen \tn 
% Row Count 12 (+ 2)
% Row 9
\SetRowColor{white}
\seqsplit{global} x & erstellen einer globalen Variable \tn 
% Row Count 14 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{x{5.9045 cm} x{5.9045 cm} x{5.061 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{built in functions}}  \tn
% Row 0
\SetRowColor{LightBackground}
print(5) & Ausgabe & \textgreater{}\textgreater{}5 \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
\seqsplit{x=input('Bitte} geben Sie eine Zahl ein: ') & Eingabe & \textgreater{}\textgreater{}Bitte geben Sie eine Zahl ein: \_ \tn 
% Row Count 4 (+ 3)
% Row 2
\SetRowColor{LightBackground}
eval('5+3') & Ausführen von Strings & \textgreater{}\textgreater{}8 \tn 
% Row Count 6 (+ 2)
% Row 3
\SetRowColor{white}
enumerate({[}1,2,3,4{]}) & erm{\"o}glicht das iterieren über Liste und Indice bei for loops &  \tn 
% Row Count 11 (+ 5)
% Row 4
\SetRowColor{LightBackground}
... & ... & ... \tn 
% Row Count 12 (+ 1)
\hhline{>{\arrayrulecolor{DarkBackground}}---}
\SetRowColor{LightBackground}
\mymulticolumn{3}{x{17.67cm}}{Es erfolgt in Python standardm{\"a}{\ss}ig keine Ausgabe, eine Unterdrückung mittels ';' ist hier also nicht üblich. Um eine Ausgabe zu erzielen, sollte auf die print() Funktion zurückgegriffen werden}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}---}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{if-Statement}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{17.67cm}}{\#if statement \newline \#auf Einschübe achten \newline if x==3: \newline    print(x) \newline elif x\textgreater{}3: \newline    print('x ist gr{\"o}{\ss}er als 3') \newline else: \newline    print('x ist zu klein') \newline  \newline \#inline if \newline \#auf Übersichtlichkeit achten!!! \newline if x==3:print(x)} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{for-Schleife}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{17.67cm}}{\# for loop \newline x={[}1,2,3,5,6,1{]} \newline for n in x: \newline    print(n) \newline  \newline \textgreater{}\textgreater{}1 \newline \textgreater{}\textgreater{}2 \newline \textgreater{}\textgreater{}3 \newline \textgreater{}\textgreater{}5 \newline \textgreater{}\textgreater{}... \newline  \newline \#erstellen, eines iterierbaren Objektes \newline x=range(3) \#exclusiver Endpunkt \newline for l in x: print(x) \newline \textgreater{}\textgreater{}0 \newline \textgreater{}\textgreater{}1 \newline \textgreater{}\textgreater{}2 \newline x=range(2,3) \#Start und exclusiver Endpunkt \newline for l in x: print(x) \newline \textgreater{}\textgreater{}2 \newline x=range(2,10,2) \#Start,exclusiver Endpunkt und Schrittweite \newline for l in x: print(x) \newline \textgreater{}\textgreater{}2 \newline \textgreater{}\textgreater{}4 \newline \textgreater{}\textgreater{}6 \newline \textgreater{}\textgreater{}8 \newline  \newline \#Liste überschreiben \newline x={[}1,3,2,6{]} \newline for n in range(len(x)): \newline    x{[}n{]}=x**2 \#jeder wert aus der Liste x wird mit seinem Quadrat überschrieben} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{While-Schleife}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{17.67cm}}{x=0 \newline while x\textless{}=10: \newline    print(x) \newline    x+=1 \newline  \newline \textgreater{}\textgreater{}0 \newline \textgreater{}\textgreater{}1 \newline \textgreater{}\textgreater{}... \newline \textgreater{}\textgreater{}10 \newline  \newline \#Endlosschleife \newline while True: \newline    print('diese Schleife l{\"a}uft solange, wie das Programm l{\"a}uft oder die Schleife abgebrochen wird')} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Abbruch von Schleifen}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{17.67cm}}{while True: \newline    break() \# sorgt für Abbruch der Schleife} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{nested loops}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{17.67cm}}{x=5 \newline while True: \newline    if x\textless{}=20: \newline       x+=1 \newline    elif x==6: \newline       for z in range(x): \newline          if z\textless{}=3: \newline             print(x) \newline          else: \newline             break() \newline    else: \newline       break()} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Struktogramme}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{p{17.67cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/niels132_1507588975_nested loops.png}}} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{17.67cm}}{Oftmals helfen Struktogramme bei der Planung von Funktionen. Im Bsp. eine nested Loop ohne jeden Sinn, sie dient lediglich der Darstellung des Struktogramms}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Funktionen}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{17.67cm}}{def \seqsplit{my\_first\_function(arg1):} \newline    print(arg1) \newline  \newline my\_first\_function(3) \newline  \newline \textgreater{}\textgreater{}3} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Arbeiten mit Dateien}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{17.67cm}}{\#Einlesen von Dateien \newline f=open(Hallo.txt,'r') \#{\"o}ffnen des Textes \newline text=f.read() \#liest den ganzen Text ein \newline f.close() \#schlie{\ss}en des Textes \newline  \newline \#zeilenweises Einlesen \newline f=open(Hallo.txt,'r') \#{\"o}ffnen des Textes \newline for line in f: \newline   x=f.readline() \newline   print(x) \# ausgabe der Zeile \newline f.close() \#schlie{\ss}en des Textes \newline  \newline \#Zeilen- und Spaltenweises einlesen einer csv-Datei \newline ''' \newline  Datei sieht z.B. wie folgt aus \newline 1,4 \newline 2,3 \newline 1,9 \newline  \newline ''' \newline  \newline f=open(Bsp.csv,'r') \#{\"o}ffnen des Textes \newline spalte\_1 = {[} {]} \newline spalte\_2 = {[} {]} \newline for line in f: \newline    x = f.readline() \newline    \seqsplit{spalte\_1.append(int(x.split('},'){[}0{]})) \newline    \seqsplit{spalte\_2.append(int(x.split('},'){[}1{]})) \newline f.close() \newline  \newline  \newline \#Dateien in eine Datei schreiben \newline \#Fall1 Datei noch nicht vorhanden oder falls sie vorhanden ist soll sie überschreiben werden \newline  \newline f=open('fall1.txt','w') \#mode 'w' für write \newline f.write('Hier steht sp{\"a}ter irgendwas') \newline f.close() \newline  \newline \#Fall2 in einer Datei weiterschreiben oder erstellen, falls sie nicht vorhanden ist \newline f=open('fall2.txt','w') \#mode 'a' für append \newline f.write('Hier steht sp{\"a}ter irgendwas') \newline f.close()} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{17.67cm}}{falls man sich nicht sicher ist sollte man auf write verzichten, da hier im schlimmsten Fall alle Daten der Datei verloren gehen!!!}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{x{2.3618 cm} x{5.3984 cm} x{9.1098 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{Module}}  \tn
% Row 0
\SetRowColor{LightBackground}
math & Konstante und Funktionen & \seqsplit{https://docs.python.org/2/library/math.html} \tn 
% Row Count 3 (+ 3)
% Row 1
\SetRowColor{white}
numpy & numerisches Python & \seqsplit{https://docs.scipy.org/doc/numpy-1.9.3/reference/} \tn 
% Row Count 6 (+ 3)
% Row 2
\SetRowColor{LightBackground}
\seqsplit{matplotlib} & graphische Darstellung & \seqsplit{http://matplotlib.org/} \tn 
% Row Count 8 (+ 2)
% Row 3
\SetRowColor{white}
\seqsplit{mayavi} & 3D Plotting & \seqsplit{http://docs.enthought.com/mayavi/mayavi/mlab.html\#d-plotting-functions-for-numpy-arrays} \tn 
% Row Count 13 (+ 5)
% Row 4
\SetRowColor{LightBackground}
\seqsplit{tkinter} & GUI & \seqsplit{http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html} \tn 
% Row Count 16 (+ 3)
% Row 5
\SetRowColor{white}
\seqsplit{pygame} & Spiele & \seqsplit{http://www.pygame.org/docs/} \tn 
% Row Count 18 (+ 2)
% Row 6
\SetRowColor{LightBackground}
\seqsplit{random} & \seqsplit{Zufallszahlen} & \seqsplit{https://docs.python.org/2/library/random.html} \tn 
% Row Count 21 (+ 3)
% Row 7
\SetRowColor{white}
os & Operating System & \seqsplit{https://docs.python.org/2/library/os.html} \tn 
% Row Count 23 (+ 2)
% Row 8
\SetRowColor{LightBackground}
time & Zeitmessung & \seqsplit{https://docs.python.org/2/library/time.html} \tn 
% Row Count 26 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}---}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{x{2.7999 cm} x{6.0939 cm} x{1.647 cm} x{5.9292 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{4}{x{17.67cm}}{\bf\textcolor{white}{Importieren von Modulen}}  \tn
% Row 0
\SetRowColor{LightBackground}
\seqsplit{import} math & Importieren des gesamten Math Modules & \seqsplit{math.sin(3)} & Modulname muss genannt werden \tn 
% Row Count 3 (+ 3)
% Row 1
\SetRowColor{white}
from math \seqsplit{import} pi & Importieren einer einzelnen Funktion aus dem Math Modul & pi & nur Funktionsname muss genannt werden \tn 
% Row Count 7 (+ 4)
% Row 2
\SetRowColor{LightBackground}
from math \seqsplit{import} * & Importieren aller Bestandteile des Math Modules & \seqsplit{sin(pi)} & da nicht das Modul, sondern alle \seqsplit{Einzelbestandteile} importiert worden sind, reicht es die \seqsplit{Funktionsnamen} anzugeben \tn 
% Row Count 16 (+ 9)
% Row 3
\SetRowColor{white}
\seqsplit{import} math as m & Importieren des Math Modules als m & \seqsplit{m.sin(m.pi)} & das Modul wird al m benannt und wird auch so aufgerufen, gleiches ist für Bestandteile von Funktionen m{\"o}glich \tn 
% Row Count 24 (+ 8)
\hhline{>{\arrayrulecolor{DarkBackground}}----}
\SetRowColor{LightBackground}
\mymulticolumn{4}{x{17.67cm}}{Es sollte immer erkenntlich sein, welche Funktionen zu welchen Modulen geh{\"o}ren, daher sollte from ... import * nur dann genutzt werden, wenn erkenntlich ist, welche Funktionen zu diesem Modul geh{\"o}ren}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}----}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{x{9.6712 cm} x{7.5988 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Math}}  \tn
% Row 0
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{import math} \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
math.sin(), math.cos(), math.tan() & Sinus, Cosinus, Tangens \tn 
% Row Count 3 (+ 2)
% Row 2
\SetRowColor{LightBackground}
math.asin(), math.acos(), math.atan() & Arcus Sinus, Cosinus, Tangens \tn 
% Row Count 5 (+ 2)
% Row 3
\SetRowColor{white}
math.e & e \tn 
% Row Count 6 (+ 1)
% Row 4
\SetRowColor{LightBackground}
math.log10() & 10er Logarithmus \tn 
% Row Count 7 (+ 1)
% Row 5
\SetRowColor{white}
math.log() & Logarithmus \tn 
% Row Count 8 (+ 1)
% Row 6
\SetRowColor{LightBackground}
math.sqrt() & Wurzel \tn 
% Row Count 9 (+ 1)
% Row 7
\SetRowColor{white}
math.pi & Pi \tn 
% Row Count 10 (+ 1)
% Row 8
\SetRowColor{LightBackground}
math.radians() & umwandlung in Radialma{\ss} \tn 
% Row Count 12 (+ 2)
% Row 9
\SetRowColor{white}
math.degree() & Umwandlung in Bogenma{\ss} \tn 
% Row Count 14 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{weitere Funktionen: \newline https://docs.python.org/2/library/math.html}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{x{6.7353 cm} x{10.5347 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Numpy}}  \tn
% Row 0
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{import numpy as np} \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
x=np.array({[}{[}1,23,3{]},{[}1{]}{]}) & erstellen eines 2D-Arrays, der NumPy-Array bietet als n-dimensionaler Array das Analogon zu einem Vektor in Matlab \tn 
% Row Count 6 (+ 5)
% Row 2
\SetRowColor{LightBackground}
x{[}:{]}{[}0{]} & \textgreater{}\textgreater{}{[}1, 23, 3{]} \tn 
% Row Count 7 (+ 1)
% Row 3
\SetRowColor{white}
x{[}0{]}{[}1{]} & \textgreater{}\textgreater{}23 \tn 
% Row Count 8 (+ 1)
% Row 4
\SetRowColor{LightBackground}
x{[}:{]}{[}:{]} & \textgreater{}\textgreater{} array({[}{[}1, 23, 3{]}, {[}1{]}{]}, dtype=object) \tn 
% Row Count 10 (+ 2)
% Row 5
\SetRowColor{white}
np.append(x{[}0{]},x{[}0{]}) & array({[} 1, 23,  3,  1, 23,  3{]}) \tn 
% Row Count 12 (+ 2)
% Row 6
\SetRowColor{LightBackground}
np.pi & Pi \tn 
% Row Count 13 (+ 1)
% Row 7
\SetRowColor{white}
np.sqrt() & Wurzel \tn 
% Row Count 14 (+ 1)
% Row 8
\SetRowColor{LightBackground}
np.sin() & Sinus \tn 
% Row Count 15 (+ 1)
% Row 9
\SetRowColor{white}
... & ... \tn 
% Row Count 16 (+ 1)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{Dokumentation: \newline https://docs.scipy.org/doc/numpy-1.9.3/user/}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{x{6.5626 cm} x{10.7074 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{matplotlib}}  \tn
% Row 0
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{import matplotlib as mpl} \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
\mymulticolumn{2}{x{17.67cm}}{import mpl.pyplot as plt} \tn 
% Row Count 2 (+ 1)
% Row 2
\SetRowColor{LightBackground}
\seqsplit{fig=plt.figure()} & erstellen einer Figure \tn 
% Row Count 4 (+ 2)
% Row 3
\SetRowColor{white}
ax=fig.gca() & Erstellen der Achsen, wobei gca für 'get current axis' steht \tn 
% Row Count 7 (+ 3)
% Row 4
\SetRowColor{LightBackground}
\seqsplit{ax.set\_xlabel('X-Achse')} & Achsenbeschriftung ({\"a}quivalent für die Y-Achse) \tn 
% Row Count 10 (+ 3)
% Row 5
\SetRowColor{white}
ax.plot({[}1,1,2{]},{[}2,1,3{]}) & plotten von Punkte (verbunden zu Linie) \tn 
% Row Count 12 (+ 2)
% Row 6
\SetRowColor{LightBackground}
plt.ylim( (0, 110) ) & Minimum und Maximum der Y-Achse festlegen analog für X-Acchse \tn 
% Row Count 15 (+ 3)
% Row 7
\SetRowColor{white}
\seqsplit{ax.invert\_yaxis()} & Invertieren der Y-Achse \tn 
% Row Count 17 (+ 2)
% Row 8
\SetRowColor{LightBackground}
ax.grid() & Gittermuster erstellen \tn 
% Row Count 18 (+ 1)
% Row 9
\SetRowColor{white}
plt.show() & Anzeigen der Graphik \tn 
% Row Count 19 (+ 1)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{Dokumentation: \newline http://matplotlib.org/}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{x{5.5264 cm} x{11.7436 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{mayavi}}  \tn
% Row 0
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{from mayavi import mlab} \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
figure = mlab.gcf() & Figure \tn 
% Row Count 3 (+ 2)
% Row 2
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{mlab.mesh(x, y, z)} \tn 
% Row Count 4 (+ 1)
% Row 3
\SetRowColor{white}
\seqsplit{mlab.plot3d()} & plotet eine Linie mit gegebenen Koordinaten X,Y,Z \tn 
% Row Count 6 (+ 2)
% Row 4
\SetRowColor{LightBackground}
mlab.show() & zeigen der aktuellen Figure \tn 
% Row Count 7 (+ 1)
% Row 5
\SetRowColor{white}
\mymulticolumn{2}{x{17.67cm}}{mlab.points3d()} \tn 
% Row Count 8 (+ 1)
% Row 6
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{mlab.surf()} \tn 
% Row Count 9 (+ 1)
% Row 7
\SetRowColor{white}
\mymulticolumn{2}{x{17.67cm}}{mlab.imshow()} \tn 
% Row Count 10 (+ 1)
% Row 8
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{mlab.contour\_surf()} \tn 
% Row Count 11 (+ 1)
% Row 9
\SetRowColor{white}
\mymulticolumn{2}{x{17.67cm}}{mlab.quiver3d()} \tn 
% Row Count 12 (+ 1)
% Row 10
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{mlab.flow()} \tn 
% Row Count 13 (+ 1)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{Dokumentation: \newline http://docs.enthought.com/mayavi/mayavi/mlab.html\#d-plotting-functions-for-numpy-arrays}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Bsp. Matplotlib 3d}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{p{17.67cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/niels132_1507586323_figure_1.png}}} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{17.67cm}}{import matplotlib as mpl  \newline from mpl\_toolkits.mplot3d import Axes3D \newline import numpy as np \newline import matplotlib.pyplot as plt \newline mpl.rcParams{[}'legend.fontsize'{]} = 10 \newline fig = plt.figure()  \newline ax = fig.gca(projection='3d')  \newline theta = np.linspace(-4 {\emph{ np.pi, 4 }} np.pi, 100) \newline z = np.linspace(-2, 2, 100) \newline r = z{\emph{*2 + 1 \newline x = r }} np.sin(theta) \newline y = r * np.cos(theta) \newline ax.plot(x, y, z, label='parametric curve') \newline ax.legend() \newline ax.set\_xlabel('X Label') \newline ax.set\_ylabel('Y Label') \newline ax.set\_zlabel('Z Label') \newline plt.show()}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{x{5.0083 cm} x{12.2617 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{os}}  \tn
% Row 0
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{import os} \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
\seqsplit{os.listdir(path)} & liefert eine Liste mit allen Dateien in einem bestimmten Pfad \tn 
% Row Count 4 (+ 3)
% Row 2
\SetRowColor{LightBackground}
\seqsplit{os.getcwd()} & liefert aktuelles Arbeitsverzeichnis \tn 
% Row Count 6 (+ 2)
% Row 3
\SetRowColor{white}
\seqsplit{os.chdir(path)} & {\"a}ndern des aktuellen Arbeitsverzeichnis (path ist ein String) \tn 
% Row Count 9 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{weitere Funktionen \newline https://docs.python.org/2/library/os.html}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{x{4.3862 cm} x{3.374 cm} x{9.1098 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{random}}  \tn
% Row 0
\SetRowColor{LightBackground}
\mymulticolumn{3}{x{17.67cm}}{import random} \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
\mymulticolumn{3}{x{17.67cm}}{x={[}1,4,5,2,7,8{]}} \tn 
% Row Count 2 (+ 1)
% Row 2
\SetRowColor{LightBackground}
\seqsplit{random.sample(x},2) & \textgreater{}\textgreater{}{[}2,5{]} & Ziehen ohne zurücklegen \tn 
% Row Count 4 (+ 2)
% Row 3
\SetRowColor{white}
\seqsplit{random.shuffle(x)} & \textgreater{}\textgreater{}{[}8,7,1,4,5,2{]} & Mischen \tn 
% Row Count 6 (+ 2)
% Row 4
\SetRowColor{LightBackground}
\seqsplit{random.choice(x)} & \textgreater{}\textgreater{}5 & Zufallsauswahl \tn 
% Row Count 8 (+ 2)
% Row 5
\SetRowColor{white}
\seqsplit{random.randint(0},9) & \textgreater{}\textgreater{}3 & Generiert einen Integer in dem Intervall {[}0,9{]} \tn 
% Row Count 11 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}---}
\SetRowColor{LightBackground}
\mymulticolumn{3}{x{17.67cm}}{Mehr Funktionen auf  \newline https://docs.python.org/2/library/random.html}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}---}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{17.67cm}{x{9.4985 cm} x{7.7715 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{time}}  \tn
% Row 0
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{import time} \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
t=time.time() & Zeitpunkt \tn 
% Row Count 2 (+ 1)
% Row 2
\SetRowColor{LightBackground}
delta\_t=time.time-t & vergangene Zeit in sec \tn 
% Row Count 4 (+ 2)
% Row 3
\SetRowColor{white}
time.strftime('\%A \%d \%m \%Y') & \textgreater{}\textgreater{}'Saturday 14 10 2017' \tn 
% Row Count 6 (+ 2)
% Row 4
\SetRowColor{LightBackground}
time.sleep(sec) & Pausieren für sec \tn 
% Row Count 7 (+ 1)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{17.67cm}}{Dokumentation: \newline https://docs.python.org/2/library/time.html}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}



\end{document}