diff options
author | Jovina | 2011-05-13 17:23:16 +0530 |
---|---|---|
committer | Jovina | 2011-05-13 17:23:16 +0530 |
commit | 44842fb6915eadadc087047a15be33f4635ed8cc (patch) | |
tree | 3fbdc8c0b1ffde89f31f59c4826786be6ced82a3 /getting_started_with_for/slides.tex | |
parent | b828875c90590e5c2c222bc5907c1e5010c65d83 (diff) | |
download | st-scripts-44842fb6915eadadc087047a15be33f4635ed8cc.tar.gz st-scripts-44842fb6915eadadc087047a15be33f4635ed8cc.tar.bz2 st-scripts-44842fb6915eadadc087047a15be33f4635ed8cc.zip |
Minor changes to scripts and slides of the 1st two modules.
Diffstat (limited to 'getting_started_with_for/slides.tex')
-rw-r--r-- | getting_started_with_for/slides.tex | 186 |
1 files changed, 60 insertions, 126 deletions
diff --git a/getting_started_with_for/slides.tex b/getting_started_with_for/slides.tex index f6c1eaa..d8706fc 100644 --- a/getting_started_with_for/slides.tex +++ b/getting_started_with_for/slides.tex @@ -1,4 +1,4 @@ -% Created 2010-10-12 Tue 12:55 +% Created 2011-05-13 Fri 12:39 \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{Getting started with for} +\title{} \author{FOSSEE} \date{} \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent} \begin{document} -\maketitle + @@ -42,30 +41,42 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries} \begin{frame} -\frametitle{Outline} -\label{sec-1} -\begin{itemize} -\item \texttt{for} loop in Python. -\item Blocks of code in Python. +\begin{center} +\textcolor{blue}{Getting started -- \texttt{for}} +\end{center} +\begin{center} +\includegraphics[scale=0.25]{../images/iitb-logo.png}\\ +Developed by FOSSEE Team, IIT-Bombay. \\ +Funded by National Mission on Education through ICT -\begin{itemize} -\item Indentation -\end{itemize} +MHRD, Govt. of India +\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 Write blocks of code in python. +\item Use the ``for`` loop. +\item Use ``range()`` function. +\item Write blocks in python interpreter +\item Write blocks in ipython interpreter. \end{itemize} \end{frame} \begin{frame}[fragile] \frametitle{Whitespace in Python} -\label{sec-2} +\label{sec-3} + \begin{itemize} \item Whitespace is significant - \begin{itemize} \item blocks are visually separated \end{itemize} - \item Blocks are indented using 4 spaces \begin{verbatim} Block A @@ -75,14 +86,14 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries} Block A \end{verbatim} - \texttt{Block B} is an inner block and is indented using 4 spaces + \verb~Block B~ is an inner block and is indented using 4 spaces \end{itemize} \end{frame} \begin{frame}[fragile] -\frametitle{Exercise 1} -\label{sec-3} +\frametitle{Question 1} +\label{sec-4} - Write a \texttt{for} loop which iterates through a list of numbers and find + Write a \verb~for~ loop which iterates through a list of numbers and find the square root of each number. \begin{verbatim} @@ -96,13 +107,13 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries} \end{frame} \begin{frame}[fragile] \frametitle{Solution 1} -\label{sec-4} +\label{sec-5} + \begin{itemize} \item Open text editor and type the following code -\end{itemize} - -\begin{verbatim} +\lstset{language=Python} +\begin{lstlisting} numbers = [1369, 7225, 3364, 7056, 5625, 729, 7056, 576, 2916] @@ -110,15 +121,17 @@ for each in numbers: print "Square root of", each, "is", sqrt(each) print "This is not in for loop!" -\end{verbatim} +\end{lstlisting} +\end{itemize} \end{frame} \begin{frame}[fragile] \frametitle{Save \& run script} -\label{sec-5} +\label{sec-6} + \begin{itemize} -\item Save the script as \texttt{list\_roots.py} -\item Run in \texttt{ipython} interpreter as, +\item Save the script as \verb~list_roots.py~ +\item Run in \verb~ipython~ interpreter as, \begin{verbatim} In []: %run -i list_roots.py \end{verbatim} @@ -126,22 +139,7 @@ print "This is not in for loop!" \end{itemize} \end{frame} \begin{frame}[fragile] -\frametitle{Exercise 2} -\label{sec-6} - - From the given numbers make a list of perfect squares and a list of those which are not. -\begin{verbatim} - -\end{verbatim} - - The numbers are, -\begin{verbatim} - 7225, 3268, 3364, 2966, 7056, 5625, 729, 5547, - 7056, 576, 2916 -\end{verbatim} -\end{frame} -\begin{frame}[fragile] -\frametitle{Exercise 3 (indentation in \texttt{ipython})} +\frametitle{Question 2} \label{sec-7} Print the square root of numbers in the list. @@ -156,58 +154,9 @@ print "This is not in for loop!" \end{verbatim} \end{frame} \begin{frame}[fragile] -\frametitle{Indentation in \texttt{ipython}} +\frametitle{Question 3} \label{sec-8} -\begin{verbatim} - In []: numbers = [1369, 7225, 3364, 7056, 5625, - ...: 729, 7056, 576, 2916] -\end{verbatim} - - -\begin{verbatim} - In []: for each in numbers: - ...: -\end{verbatim} - - Note the four spaces here -\begin{verbatim} - - - - - - -\end{verbatim} -\end{frame} -\begin{frame}[fragile] -\frametitle{Indentation in \texttt{ipython} (cont'd)} -\label{sec-9} - -\begin{verbatim} - In []: numbers = [1369, 7225, 3364, 7056, 5625, - ...: 729, 7056, 576, 2916] - In []: for each in numbers: - ...: -\end{verbatim} - - Note the four spaces here -\begin{verbatim} - -\end{verbatim} - - Now type the rest of the code -\begin{verbatim} - ...: print "Square root of", each, - ...: print "is", sqrt(each) - ...: - ...: -\end{verbatim} -\end{frame} -\begin{frame}[fragile] -\frametitle{Indentation in \texttt{python} interpreter} -\label{sec-10} - Find out the cube of all the numbers from 1 to 10. \begin{verbatim} @@ -215,71 +164,56 @@ print "This is not in for loop!" \emph{do it in the python interpreter} \end{frame} -\begin{frame}[fragile] -\frametitle{Indentation in \texttt{python} interpreter (cont'd)} -\label{sec-11} - -\begin{verbatim} ->>> for i in range(1, 11): -... print i, "cube is", i**3 -... -\end{verbatim} -\end{frame} \begin{frame} -\frametitle{\texttt{range()} function} -\label{sec-12} +\frametitle{\verb~range()~ function} +\label{sec-9} + \begin{itemize} \item in built function in Python \item generates a list of integers - \begin{itemize} \item \emph{syntax:} range([start,] stop[, step]) \item \emph{example:} - \begin{itemize} \item range(1, 20) - \emph{generates integers from 1 to 20} \item range(20) - \emph{generates integers from 0 to 20} \end{itemize} - \end{itemize} - \end{itemize} \end{frame} \begin{frame} -\frametitle{Exercise 4} -\label{sec-13} +\frametitle{Question 4} +\label{sec-10} Print all the odd numbers from 1 to 50. \end{frame} \begin{frame} \frametitle{Summary} -\label{sec-14} +\label{sec-11} + + In this tutorial,we learnt to, \begin{itemize} -\item blocks in \texttt{python} -\item indentation -\item blocks in \texttt{ipython} interpreter -\item \texttt{for} loop -\item iterating over list using \texttt{for} loop -\item \texttt{range()} function +\item Create blocks in python using ``for +\item Indent the blocks of code +\item Iterate over a list using ``for`` loop +\item Use the ``range()`` function \end{itemize} \end{frame} \begin{frame} -\frametitle{Thank you!} -\label{sec-15} \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 |