getting-started-with-for/slides.tex
author anand
Mon, 08 Nov 2010 01:36:47 +0530
changeset 455 f5b7d0b693d9
parent 306 f105cfcc2498
permissions -rw-r--r--
checklist OK
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
306
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
     1
% Created 2010-10-12 Tue 12:55
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
     2
\documentclass[presentation]{beamer}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
     3
\usepackage[latin1]{inputenc}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
     4
\usepackage[T1]{fontenc}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
     5
\usepackage{fixltx2e}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
     6
\usepackage{graphicx}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
     7
\usepackage{longtable}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
     8
\usepackage{float}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
     9
\usepackage{wrapfig}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    10
\usepackage{soul}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    11
\usepackage{t1enc}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    12
\usepackage{textcomp}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    13
\usepackage{marvosym}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    14
\usepackage{wasysym}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    15
\usepackage{latexsym}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    16
\usepackage{amssymb}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    17
\usepackage{hyperref}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    18
\tolerance=1000
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    19
\usepackage[english]{babel} \usepackage{ae,aecompl}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    20
\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    21
\usepackage{listings}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    22
\lstset{language=Python, basicstyle=\ttfamily\bfseries,
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    23
commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    24
showstringspaces=false, keywordstyle=\color{blue}\bfseries}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    25
\providecommand{\alert}[1]{\textbf{#1}}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    26
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    27
\title{Getting started with for}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    28
\author{FOSSEE}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    29
\date{}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    30
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    31
\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    32
\begin{document}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    33
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    34
\maketitle
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    35
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    36
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    37
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    38
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    39
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    40
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    41
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    42
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    43
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    44
\begin{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    45
\frametitle{Outline}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    46
\label{sec-1}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    47
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    48
\begin{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    49
\item \texttt{for} loop in Python.
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    50
\item Blocks of code in Python.
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    51
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    52
\begin{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    53
\item Indentation
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    54
\end{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    55
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    56
\end{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    57
\end{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    58
\begin{frame}[fragile]
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    59
\frametitle{Whitespace in Python}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    60
\label{sec-2}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    61
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    62
\begin{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    63
\item Whitespace is significant
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    64
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    65
\begin{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    66
\item blocks are visually separated
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    67
\end{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    68
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    69
\item Blocks are indented using 4 spaces
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    70
\begin{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    71
     Block A
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    72
     Block A
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    73
         Block B
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    74
         Block B
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    75
     Block A
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    76
\end{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    77
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    78
    \texttt{Block B} is an inner block and is indented using 4 spaces
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    79
\end{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    80
\end{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    81
\begin{frame}[fragile]
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    82
\frametitle{Exercise 1}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    83
\label{sec-3}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    84
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    85
  Write a \texttt{for} loop which iterates through a list of numbers and find
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    86
  the square root of each number.
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    87
\begin{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    88
   
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    89
\end{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    90
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    91
  The numbers are,
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    92
\begin{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    93
   1369, 7225, 3364, 7056, 5625, 729, 7056, 
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    94
   576, 2916
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    95
\end{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    96
\end{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    97
\begin{frame}[fragile]
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    98
\frametitle{Solution 1}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    99
\label{sec-4}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   100
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   101
\begin{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   102
\item Open text editor and type the following code
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   103
\end{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   104
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   105
\begin{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   106
numbers = [1369, 7225, 3364, 7056, 5625, 729, 7056, 
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   107
           576, 2916]
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   108
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   109
for each in numbers:
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   110
    print "Square root of", each, "is", sqrt(each)
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   111
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   112
print "This is not in for loop!"
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   113
\end{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   114
\end{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   115
\begin{frame}[fragile]
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   116
\frametitle{Save \& run script}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   117
\label{sec-5}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   118
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   119
\begin{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   120
\item Save the script as \texttt{list\_roots.py}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   121
\item Run in \texttt{ipython} interpreter as,
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   122
\begin{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   123
     In []: %run -i list_roots.py
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   124
\end{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   125
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   126
\end{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   127
\end{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   128
\begin{frame}[fragile]
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   129
\frametitle{Exercise 2}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   130
\label{sec-6}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   131
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   132
  From the given numbers make a list of perfect squares and a list of those which are not.
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   133
\begin{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   134
   
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   135
\end{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   136
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   137
  The numbers are,
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   138
\begin{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   139
   7225, 3268, 3364, 2966, 7056, 5625, 729, 5547, 
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   140
   7056, 576, 2916
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   141
\end{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   142
\end{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   143
\begin{frame}[fragile]
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   144
\frametitle{Exercise 3 (indentation in \texttt{ipython})}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   145
\label{sec-7}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   146
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   147
  Print the square root of numbers in the list.
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   148
\begin{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   149
   
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   150
\end{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   151
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   152
  Numbers are,
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   153
\begin{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   154
   7225, 3268, 3364, 2966, 7056, 5625, 729, 5547, 
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   155
   7056, 576, 2916
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   156
\end{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   157
\end{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   158
\begin{frame}[fragile]
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   159
\frametitle{Indentation in \texttt{ipython}}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   160
\label{sec-8}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   161
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   162
\begin{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   163
   In []: numbers = [1369, 7225, 3364, 7056, 5625, 
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   164
     ...:  729, 7056, 576, 2916]
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   165
\end{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   166
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   167
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   168
\begin{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   169
   In []: for each in numbers:
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   170
     ...:     
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   171
\end{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   172
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   173
  Note the four spaces here
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   174
\begin{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   175
   
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   176
   
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   177
   
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   178
   
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   179
   
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   180
   
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   181
\end{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   182
\end{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   183
\begin{frame}[fragile]
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   184
\frametitle{Indentation in \texttt{ipython} (cont'd)}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   185
\label{sec-9}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   186
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   187
\begin{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   188
   In []: numbers = [1369, 7225, 3364, 7056, 5625, 
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   189
     ...:  729, 7056, 576, 2916]
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   190
   In []: for each in numbers:
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   191
     ...:     
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   192
\end{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   193
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   194
  Note the four spaces here
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   195
\begin{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   196
   
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   197
\end{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   198
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   199
  Now type the rest of the code
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   200
\begin{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   201
     ...:     print "Square root of", each, 
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   202
     ...:     print "is", sqrt(each)
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   203
     ...:     
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   204
     ...:     
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   205
\end{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   206
\end{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   207
\begin{frame}[fragile]
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   208
\frametitle{Indentation in \texttt{python} interpreter}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   209
\label{sec-10}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   210
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   211
  Find out the cube of all the numbers from 1 to 10.
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   212
\begin{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   213
   
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   214
\end{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   215
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   216
  \emph{do it in the python interpreter}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   217
\end{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   218
\begin{frame}[fragile]
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   219
\frametitle{Indentation in \texttt{python} interpreter (cont'd)}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   220
\label{sec-11}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   221
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   222
\begin{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   223
>>> for i in range(1, 11):
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   224
...     print i, "cube is", i**3
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   225
...
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   226
\end{verbatim}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   227
\end{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   228
\begin{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   229
\frametitle{\texttt{range()} function}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   230
\label{sec-12}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   231
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   232
\begin{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   233
\item in built function in Python
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   234
\item generates a list of integers
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   235
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   236
\begin{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   237
\item \emph{syntax:} range([start,] stop[, step])
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   238
\item \emph{example:}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   239
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   240
\begin{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   241
\item range(1, 20) - \emph{generates integers from 1 to 20}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   242
\item range(20) - \emph{generates integers from 0 to 20}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   243
\end{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   244
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   245
\end{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   246
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   247
\end{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   248
\end{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   249
\begin{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   250
\frametitle{Exercise 4}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   251
\label{sec-13}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   252
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   253
  Print all the odd numbers from 1 to 50.
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   254
\end{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   255
\begin{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   256
\frametitle{Summary}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   257
\label{sec-14}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   258
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   259
\begin{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   260
\item blocks in \texttt{python}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   261
\item indentation
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   262
\item blocks in \texttt{ipython} interpreter
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   263
\item \texttt{for} loop
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   264
\item iterating over list using \texttt{for} loop
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   265
\item \texttt{range()} function
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   266
\end{itemize}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   267
\end{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   268
\begin{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   269
\frametitle{Thank you!}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   270
\label{sec-15}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   271
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   272
  \begin{block}{}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   273
  \begin{center}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   274
  This spoken tutorial has been produced by the
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   275
  \textcolor{blue}{FOSSEE} team, which is funded by the 
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   276
  \end{center}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   277
  \begin{center}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   278
    \textcolor{blue}{National Mission on Education through \\
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   279
      Information \& Communication Technology \\ 
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   280
      MHRD, Govt. of India}.
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   281
  \end{center}  
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   282
  \end{block}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   283
\end{frame}
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   284
f105cfcc2498 added slides for getting-started-with-for.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   285
\end{document}