summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--using_python_modules/slides.org92
-rw-r--r--using_python_modules/slides.tex189
2 files changed, 207 insertions, 74 deletions
diff --git a/using_python_modules/slides.org b/using_python_modules/slides.org
index 46f6dc9..199e63a 100644
--- a/using_python_modules/slides.org
+++ b/using_python_modules/slides.org
@@ -18,7 +18,7 @@
#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
-#+TITLE: Using python modules
+#+TITLE:
#+AUTHOR: FOSSEE
#+EMAIL:
#+DATE:
@@ -29,11 +29,35 @@
#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
-* Outline
- - Running python scripts from command line
- - Importing python modules
- - Importing scipy \& pylab modules
- - About python standard library.
+*
+#+begin_latex
+\begin{center}
+\vspace{12pt}
+\textcolor{blue}{\huge Using python modules}
+\end{center}
+\vspace{18pt}
+\begin{center}
+\vspace{10pt}
+\includegraphics[scale=0.95]{../images/fossee-logo.png}\\
+\vspace{5pt}
+\scriptsize Developed by FOSSEE Team, IIT-Bombay. \\
+\scriptsize Funded by National Mission on Education through ICT\\
+\scriptsize MHRD,Govt. of India\\
+\includegraphics[scale=0.30]{../images/iitb-logo.png}\\
+\end{center}
+#+end_latex
+* Objectives
+ At the end of this tutorial, you will be able to ,
+
+ - Execute python scripts from command line.
+ - Use import in scripts.
+ - Import scipy and pylab modules.
+ - Use python standard modules and 3rd party modules.
+* Pre-requisite
+Spoken tutorial on -
+- Using plot interactively.
+- Embellishing a plot.
+- Saving plots.
* Running Python script from command line
- Create a script, open text editor and type the following
: print "hello world!"
@@ -78,7 +102,7 @@
pylab.ylim(-5*scipy.pi, 5*scipy.pi)
#+end_src
* Exercise 1
- Write a python script to plot a sine wave from
+ - Write a python script to plot a sine wave from
#+begin_latex
$-2\Pi$
#+end_latex
@@ -103,21 +127,53 @@
- More information
- [[http://docs.python.org/library]]
* Summary
- - Running scripts from command line
- - Learned about modules
- - importing modules
- - Python standard library
-* Thank you!
+ In this tutorial, we have learnt to,
+
+ - Run scripts from command line,
+ - Import modules by specifying the module name followed by
+ an asterisk.
+ - Import only the required functions from modules by specifying
+ the function name.
+ - Use python standard library.
+* Evaluation
+1. Which among this is correct ?
+
+ - from scipy import plot
+ - from numpy import plot
+ - from matplotlib import plot
+ - from pylab import plot
+
+2. Which among these libraries is part of python standard library ?
+
+ - Mayavi
+ - scipy
+ - matplotlib
+ - urllib2
+
+3. Functions ``xlim()'' and ``ylim()'' can be imported to the current
+ name-space as,
+
+ - from pylab import xlim, ylim
+ - import pylab
+ - from scipy import xlim, ylim
+ - import scipy
+* Solutions
+1. from pylab import plot
+
+2. urllib2
+
+3. from pylab import xlim, ylim
+*
#+begin_latex
- \begin{block}{}
+ \begin{block}{}
\begin{center}
- This spoken tutorial has been produced by the
- \textcolor{blue}{FOSSEE} team, which is funded by the
+ \textcolor{blue}{\Large THANK YOU!}
\end{center}
+ \end{block}
+\begin{block}{}
\begin{center}
- \textcolor{blue}{National Mission on Education through \\
- Information \& Communication Technology \\
- MHRD, Govt. of India}.
+ For more Information, visit our website\\
+ \url{http://fossee.in/}
\end{center}
\end{block}
#+end_latex
diff --git a/using_python_modules/slides.tex b/using_python_modules/slides.tex
index 08c954b..9028206 100644
--- a/using_python_modules/slides.tex
+++ b/using_python_modules/slides.tex
@@ -1,4 +1,4 @@
-% Created 2010-10-12 Tue 17:12
+% Created 2011-07-13 Wed 15:46
\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
@@ -8,7 +8,6 @@
\usepackage{float}
\usepackage{wrapfig}
\usepackage{soul}
-\usepackage{t1enc}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
@@ -24,14 +23,14 @@ commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
showstringspaces=false, keywordstyle=\color{blue}\bfseries}
\providecommand{\alert}[1]{\textbf{#1}}
-\title{Using python modules}
+\title{}
\author{FOSSEE}
\date{}
\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
-\maketitle
+
@@ -42,19 +41,52 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries}
\begin{frame}
-\frametitle{Outline}
-\label{sec-1}
+
+\begin{center}
+\vspace{12pt}
+\textcolor{blue}{\huge Using python modules}
+\end{center}
+\vspace{18pt}
+\begin{center}
+\vspace{10pt}
+\includegraphics[scale=0.95]{../images/fossee-logo.png}\\
+\vspace{5pt}
+\scriptsize Developed by FOSSEE Team, IIT-Bombay. \\
+\scriptsize Funded by National Mission on Education through ICT\\
+\scriptsize MHRD,Govt. of India\\
+\includegraphics[scale=0.30]{../images/iitb-logo.png}\\
+\end{center}
+\end{frame}
+\begin{frame}
+\frametitle{Objectives}
+\label{sec-2}
+
+ At the end of this tutorial, you will be able to ,
+
\begin{itemize}
-\item Running python scripts from command line
-\item Importing python modules
-\item Importing scipy \& pylab modules
-\item About python standard library.
+\item Execute python scripts from command line.
+\item Use import in scripts.
+\item Import scipy and pylab modules.
+\item Use python standard modules and 3rd party modules.
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Pre-requisite}
+\label{sec-3}
+
+Spoken tutorial on -
+
+\begin{itemize}
+\item Using plot interactively.
+\item Embellishing a plot.
+\item Saving plots.
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{Running Python script from command line}
-\label{sec-2}
+\label{sec-4}
+
\begin{itemize}
\item Create a script, open text editor and type the following
@@ -63,12 +95,13 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries}
print
\end{verbatim}
-\item Save the script as \texttt{hello.py}
+\item Save the script as \verb~hello.py~
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{Running Python script from command line (cont'd)}
-\label{sec-3}
+\label{sec-5}
+
\begin{itemize}
\item Run the script
@@ -77,28 +110,27 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries}
\end{verbatim}
\end{itemize}
-
\emph{Syntax :} \textbf{python filename}
\end{frame}
\begin{frame}
\frametitle{Four plot problem}
-\label{sec-4}
+\label{sec-6}
\begin{center}
\includegraphics[scale=0.4]{four_plot}
\end{center}
\end{frame}
\begin{frame}[fragile]
-\frametitle{Fix \texttt{linspace()} problem}
-\label{sec-5}
+\frametitle{Fix \verb~linspace()~ problem}
+\label{sec-7}
\begin{verbatim}
from scipy import *
\end{verbatim}
\end{frame}
\begin{frame}[fragile]
-\frametitle{Fix \texttt{plot()} problem}
-\label{sec-6}
+\frametitle{Fix \verb~plot()~ problem}
+\label{sec-8}
\begin{verbatim}
from pylab import *
@@ -106,7 +138,7 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries}
\end{frame}
\begin{frame}[fragile]
\frametitle{Better way of fixing}
-\label{sec-7}
+\label{sec-9}
\begin{verbatim}
from scipy import linspace
@@ -117,11 +149,11 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries}
from scipy import *
\end{verbatim}
- \texttt{*} means import all functions from name-space \texttt{scipy}.
+ \verb~*~ means import all functions from name-space \verb~scipy~.
\end{frame}
\begin{frame}[fragile]
-\frametitle{Instead of \texttt{*}}
-\label{sec-8}
+\frametitle{Instead of \verb~*~}
+\label{sec-10}
\begin{verbatim}
from scipy import linspace, pi, sin
@@ -129,13 +161,14 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries}
from pylab import xlim, ylim, title, show
\end{verbatim}
- Is better than, \texttt{from scipy import *} \& \texttt{from pylab import *}.
+ Is better than, \verb~from scipy import *~ \& \verb~from pylab import *~.
\end{frame}
\begin{frame}[fragile]
\frametitle{Another Fix}
-\label{sec-9}
+\label{sec-11}
-\begin{verbatim}
+\lstset{language=Python}
+\begin{lstlisting}
import scipy
import pylab
x = scipy.linspace(-5*scipy.pi, 5*scipy.pi, 500)
@@ -147,21 +180,24 @@ pylab.legend(['x', '-x', 'sin(x)', 'xsin(x)'])
pylab.annotate('origin', xy = (0, 0))
pylab.xlim(-5*scipy.pi, 5*scipy.pi)
pylab.ylim(-5*scipy.pi, 5*scipy.pi)
-\end{verbatim}
+\end{lstlisting}
\end{frame}
\begin{frame}
\frametitle{Exercise 1}
-\label{sec-10}
+\label{sec-12}
+
- Write a python script to plot a sine wave from
+\begin{itemize}
+\item Write a python script to plot a sine wave from
$-2\Pi$
to
$2\Pi$
.
+\end{itemize}
\end{frame}
\begin{frame}
\frametitle{What is a module?}
-\label{sec-11}
+\label{sec-13}
Module is simply a file containing Python definitions and
statements. Definitions from a module can be imported into other
@@ -169,59 +205,100 @@ pylab.ylim(-5*scipy.pi, 5*scipy.pi)
\end{frame}
\begin{frame}
\frametitle{Python standard library}
-\label{sec-12}
+\label{sec-14}
Python has a very rich standard library of modules.
+
\begin{itemize}
\item Few libraries
-
\begin{itemize}
-\item Math: \texttt{math}, \texttt{random}
-\item Internet access: \texttt{urllib2}, \texttt{smtplib}
-\item System, Command line arguments: \texttt{sys}
-\item Operating system interface: \texttt{os}
-\item regular expressions: \texttt{re}
-\item compression: \texttt{gzip}, \texttt{zipfile}, \texttt{tarfile}
+\item Math: \verb~math~, \verb~random~
+\item Internet access: \verb~urllib2~, \verb~smtplib~
+\item System, Command line arguments: \verb~sys~
+\item Operating system interface: \verb~os~
+\item regular expressions: \verb~re~
+\item compression: \verb~gzip~, \verb~zipfile~, \verb~tarfile~
\end{itemize}
-
\item More information
-
\begin{itemize}
\item \href{http://docs.python.org/library}{http://docs.python.org/library}
\end{itemize}
-
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Summary}
-\label{sec-13}
+\label{sec-15}
+
+ In this tutorial, we have learnt to,
-\begin{itemize}
-\item Running scripts from command line
-\item Learned about modules
\begin{itemize}
-\item importing modules
+\item Run scripts from command line,
+\item Import modules by specifying the module name followed by
+ an asterisk.
+\item Import only the required functions from modules by specifying
+ the function name.
+\item Use python standard library.
\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Evaluation}
+\label{sec-16}
-\item Python standard library
+
+\begin{enumerate}
+\item Which among this is correct ?
+\begin{itemize}
+\item from scipy import plot
+\item from numpy import plot
+\item from matplotlib import plot
+\item from pylab import plot
+\end{itemize}
+\vspace{2pt}
+\item Which among these libraries is part of python standard library ?
+\begin{itemize}
+\item Mayavi
+\item scipy
+\item matplotlib
+\item urllib2
\end{itemize}
+\vspace{2pt}
+\item Functions ``xlim()'' and ``ylim()'' can be imported to the current
+ name-space as,
+\begin{itemize}
+\item from pylab import xlim, ylim
+\item import pylab
+\item from scipy import xlim, ylim
+\item import scipy
+\end{itemize}
+\end{enumerate}
\end{frame}
\begin{frame}
-\frametitle{Thank you!}
-\label{sec-14}
+\frametitle{Solutions}
+\label{sec-17}
+
- \begin{block}{}
+\begin{enumerate}
+\item from pylab import plot
+\vspace{12pt}
+\item urllib2
+\vspace{12pt}
+\item from pylab import xlim, ylim
+\end{enumerate}
+\end{frame}
+\begin{frame}
+
+ \begin{block}{}
\begin{center}
- This spoken tutorial has been produced by the
- \textcolor{blue}{FOSSEE} team, which is funded by the
+ \textcolor{blue}{\Large THANK YOU!}
\end{center}
+ \end{block}
+\begin{block}{}
\begin{center}
- \textcolor{blue}{National Mission on Education through \\
- Information \& Communication Technology \\
- MHRD, Govt. of India}.
+ For more Information, visit our website\\
+ \url{http://fossee.in/}
\end{center}
\end{block}
\end{frame}
-\end{document}
+\end{document} \ No newline at end of file