-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasics.tex
109 lines (61 loc) · 1.64 KB
/
Basics.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
\section{Basics}
\subsection{Hello, World!}
\begin{frame}[fragile]{Scientific \emph{Hello, World!}}
\begin{columns}
\column{0.65\textwidth}
\input{Pygsnippets/HelloWorld.tex}
\column{0.4\textwidth}
cmp. H.-P. Langtangen, "Python Scripting for Computational Science"\\[1ex]
run with:
\begin{verbatim}
python HelloWorld.py 0.0
\end{verbatim}
\end{columns}
\end{frame}
\subsection{Basic Python}
\begin{frame}[fragile]{Control structures}
\input{Pygsnippets/controlStructures.tex}
\end{frame}
\begin{frame}[fragile]{Functions}
\input{Pygsnippets/Functions.tex}
\end{frame}
\begin{frame}[fragile]{Data types}
\input{Pygsnippets/DataTypes.tex}
\end{frame}
\begin{frame}[fragile]{Files}
\input{Pygsnippets/Files.tex}
\begin{columns}
\column{0.5\textwidth}
{\texttt infile}:
\begin{verbatim}
1.0 2.0
3.0 4.0
\end{verbatim}
\column{0.5\textwidth}
{\texttt outfile}:
\begin{verbatim}
1.0 * 2.0 = 2.0
3.0 * 4.0 = 12.0
\end{verbatim}
\end{columns}
\end{frame}
\subsection{Modules}
\begin{frame}{Reusing code: modules}
Place code to be reused in {\texttt{Module.py:}}
\input{Pygsnippets/Module.tex}
In {\texttt{somewhereElse.py}}, do something like:
\input{Pygsnippets/somewhereElse.tex}
\end{frame}
\subsection{Magic}
\begin{frame}{Some Python magic}
\input{Pygsnippets/magic.tex}
\end{frame}
\begin{frame}{Pitfalls}
$\lightning$ Common pitfalls:
\begin{itemize}
\item slicing: last index is \emph{exclusive}, not \emph{inclusive} as in e.g. Fortran
\input{Pygsnippets/Pitfalls1.tex}
\item What looks like performing an assignment is actually setting a reference:
\input{Pygsnippets/Pitfalls2.tex}
\end{itemize}
\end{frame}