diff options
author | Jovina | 2011-09-19 16:52:15 +0530 |
---|---|---|
committer | Jovina | 2011-09-19 16:52:15 +0530 |
commit | b50e99f58a8ffc40b977120dd486eb0513aa3b8b (patch) | |
tree | 910e8e17b5e404b1511a2daf988dfd32a5664e15 /advanced_python/slides/modules.tex | |
parent | c8dbfd6beae678d309a4a45328f24763afeac078 (diff) | |
download | sees-b50e99f58a8ffc40b977120dd486eb0513aa3b8b.tar.gz sees-b50e99f58a8ffc40b977120dd486eb0513aa3b8b.tar.bz2 sees-b50e99f58a8ffc40b977120dd486eb0513aa3b8b.zip |
Modified slides of 'basic Python' and 'Advanced Python' .
Diffstat (limited to 'advanced_python/slides/modules.tex')
-rw-r--r-- | advanced_python/slides/modules.tex | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/advanced_python/slides/modules.tex b/advanced_python/slides/modules.tex index 957789a..edae339 100644 --- a/advanced_python/slides/modules.tex +++ b/advanced_python/slides/modules.tex @@ -6,13 +6,13 @@ \item Script to print `hello world' -- \texttt{hello.py} \end{itemize} \begin{lstlisting} - print "Hello world!" + In []: print "Hello world!" \end{lstlisting} \begin{itemize} \item We have been running scripts from IPython \end{itemize} \begin{lstlisting} - %run -i hello.py + In []: %run -i hello.py \end{lstlisting} \begin{itemize} \item Now, we run from the shell using python @@ -28,9 +28,9 @@ \item Save the following in \texttt{sine\_plot.py} \end{itemize} \begin{lstlisting} - x = linspace(-2*pi, 2*pi, 100) - plot(x, sin(x)) - show() + In []: x = linspace(-2*pi, 2*pi, 100) + In []: plot(x, sin(x)) + In []: show() \end{lstlisting} \begin{itemize} \item Now, let us run the script @@ -103,19 +103,20 @@ \item Save it as \texttt{gcd\_script.py} \end{itemize} \begin{lstlisting} - def gcd(a, b): - while b: - a, b = b, a%b - return a + In []: def gcd(a, b): + .... while b: + .... a, b = b, a%b + .... return a + .... \end{lstlisting} \begin{itemize} \item Also add the tests to the file \end{itemize} \begin{lstlisting} - if gcd(40, 12) == 4 and gcd(12, 13) == 1: - print "Everything OK" - else: - print "The GCD function is wrong" + .... if gcd(40, 12) == 4 and gcd(12, 13) == 1: + .... print "Everything OK" + .... else: + .... print "The GCD function is wrong" \end{lstlisting} \begin{lstlisting} $ python gcd_script.py |