new indexing figures for python
This commit is contained in:
parent
63ed109d4d
commit
da6a3eef44
1886
programming/images/arrayIndexing_py.pdf
Normal file
1886
programming/images/arrayIndexing_py.pdf
Normal file
File diff suppressed because one or more lines are too long
4176
programming/images/matrixIndexing_py.pdf
Normal file
4176
programming/images/matrixIndexing_py.pdf
Normal file
File diff suppressed because one or more lines are too long
@ -2,8 +2,20 @@
|
|||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
\chapter{Programming in Python}
|
\chapter{Programming in Python}
|
||||||
|
|
||||||
|
Python is a rather young and very dynamic programming languages which
|
||||||
|
attracts more and more users in the sciences. One of the reasons is
|
||||||
|
that python is an expressive language, that means, the program code
|
||||||
|
can often be literally read and understood. Another aspect is the
|
||||||
|
strong community support. Most packages are developed by open-source
|
||||||
|
enthusiasts who are willing to share their code and knowledge thus,
|
||||||
|
answers to most problems can be found with a simple internet search.
|
||||||
|
|
||||||
\section{Variables and Datatypes}
|
\section{Variables and Datatypes}
|
||||||
|
|
||||||
|
Befor we can start to solve programming problems we have to know a few
|
||||||
|
basic things about the programming language. In this chapter the
|
||||||
|
basic concepts and the python syntax will be introduced.
|
||||||
|
|
||||||
\subsection{Variables}
|
\subsection{Variables}
|
||||||
|
|
||||||
A \enterm{variable} is basically a pointer to a place in a computer's
|
A \enterm{variable} is basically a pointer to a place in a computer's
|
||||||
@ -18,7 +30,6 @@ same bitpattern is stored but the interpretation as an 8-bit
|
|||||||
\enterm{integer} leads to the numeric value of 38 while an
|
\enterm{integer} leads to the numeric value of 38 while an
|
||||||
interpretation as a \enterm{character} lead to the ampersand symbol.
|
interpretation as a \enterm{character} lead to the ampersand symbol.
|
||||||
|
|
||||||
|
|
||||||
\begin{figure}
|
\begin{figure}
|
||||||
\centering
|
\centering
|
||||||
\begin{subfigure}{.5\textwidth}
|
\begin{subfigure}{.5\textwidth}
|
||||||
@ -43,11 +54,13 @@ Variables can be created at any time at any place in a python
|
|||||||
program. Listing \ref{varListing1} shows different ways to do this:
|
program. Listing \ref{varListing1} shows different ways to do this:
|
||||||
|
|
||||||
\begin{lstlisting}[label=varListing1, caption={Creating variables.}, language=python]
|
\begin{lstlisting}[label=varListing1, caption={Creating variables.}, language=python]
|
||||||
|
w = 3.1415
|
||||||
x = 38
|
x = 38
|
||||||
y = None
|
y = 'A'
|
||||||
z = 'A'
|
z = None
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
|
|
||||||
|
Line one creates
|
||||||
Die Zeile 1 kann etwa so gelesen werden:''Erzeuge eine Variable mit
|
Die Zeile 1 kann etwa so gelesen werden:''Erzeuge eine Variable mit
|
||||||
dem Namen \varcode{x} und weise ihr den Wert 38 zu''. Das
|
dem Namen \varcode{x} und weise ihr den Wert 38 zu''. Das
|
||||||
Gleichheitszeichen ist der sogenannte
|
Gleichheitszeichen ist der sogenannte
|
||||||
@ -299,7 +312,7 @@ ans =
|
|||||||
|
|
||||||
\subsubsection{Zugriff auf Inhalte von Vektoren}
|
\subsubsection{Zugriff auf Inhalte von Vektoren}
|
||||||
\begin{figure}
|
\begin{figure}
|
||||||
\includegraphics[width=0.4\columnwidth]{arrayIndexing}
|
\includegraphics[width=0.4\columnwidth]{arrayIndexing_py}
|
||||||
\titlecaption{Indices von Vektoren.}{Jedes Feld eines Vektors hat
|
\titlecaption{Indices von Vektoren.}{Jedes Feld eines Vektors hat
|
||||||
einen Index (kleine Zahl) mit dem auf den jeweiligen Inhalt
|
einen Index (kleine Zahl) mit dem auf den jeweiligen Inhalt
|
||||||
(gro{\ss}e Zahl) zugegriffen werden
|
(gro{\ss}e Zahl) zugegriffen werden
|
||||||
@ -593,7 +606,7 @@ die Gr\"o{\ss}e der l\"angsten Dimension aus. Die \code{size()}-Funktion
|
|||||||
gibt dagegen die L\"ange jeder Dimension als Vektor zur\"uck.
|
gibt dagegen die L\"ange jeder Dimension als Vektor zur\"uck.
|
||||||
|
|
||||||
\begin{figure}
|
\begin{figure}
|
||||||
\includegraphics[width=0.9\columnwidth]{matrixIndexing}
|
\includegraphics[width=0.9\columnwidth]{matrixIndexing_py}
|
||||||
\titlecaption{Indices von Matrizen.}{Jedes Feld einer Matrize
|
\titlecaption{Indices von Matrizen.}{Jedes Feld einer Matrize
|
||||||
wird durch einen Index individuell angesprochen. Der Index setzt
|
wird durch einen Index individuell angesprochen. Der Index setzt
|
||||||
sich aus so vielen Zahlen zusammen wie es Dimensionen gibt (links
|
sich aus so vielen Zahlen zusammen wie es Dimensionen gibt (links
|
||||||
|
Reference in New Issue
Block a user