day2/cheatsheet3.tex
changeset 301 49bdffe4dca5
child 327 c78cad28c2f7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day2/cheatsheet3.tex	Wed Nov 11 12:26:07 2009 +0530
@@ -0,0 +1,65 @@
+\documentclass[12pt]{article}
+
+
+\title{Python: Data Structures}
+\author{FOSSEE}
+\usepackage{listings}
+\lstset{language=Python,
+    basicstyle=\ttfamily,
+commentstyle=\itshape\bfseries, 
+showstringspaces=false
+}
+\newcommand{\typ}[1]{\lstinline{#1}}
+\usepackage[english]{babel}
+\usepackage[latin1]{inputenc}
+\usepackage{times}
+\usepackage[T1]{fontenc}
+\usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler}
+\usepackage[scaled=.95]{helvet}
+
+\begin{document}
+\date{}
+\vspace{-1in}
+\begin{center}
+\LARGE{Python: Functions and Objects}\\
+\large{FOSSEE}
+\end{center}
+\section{Functions}
+Function definition
+  \begin{lstlisting}
+def signum( r ):    
+    if r < 0:
+        return -1
+    elif r > 0:
+        return 1
+    else:
+        return 0
+  \end{lstlisting}
+Default Arguments 
+\begin{lstlisting}
+def welcome(greet, name='world!'):
+    print greet, name
+\end{lstlisting}
+Keyword Arguments
+\begin{lstlisting}
+In []: plot(y, sin(y), 'g', linewidth=2)
+\end{lstlisting}
+Self contained python script
+  \begin{lstlisting}
+from scipy import linspace, pi, sin
+from pylab import plot, legend, annotate
+from pylab import xlim, ylim
+
+x = linspace(-5*pi, 5*pi, 500)
+plot(x, x, 'b')
+plot(x, -x, 'b')
+plot(x, sin(x), 'g', linewidth=2)
+plot(x, x*sin(x), 'r', linewidth=3)
+legend(['x', '-x', 'sin(x)', 'xsin(x)'])
+annotate('origin', xy = (0, 0))
+xlim(-5*pi, 5*pi)
+ylim(-5*pi, 5*pi)
+  \end{lstlisting}
+
+\end{document}