author | amit |
Wed, 27 Oct 2010 15:13:17 +0530 | |
changeset 362 | a77a27916f81 |
parent 278 | 461a68dbefb1 |
child 365 | 0fbe8a18587f |
permissions | -rw-r--r-- |
278
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
1 |
% Created 2010-10-10 Sun 21:15 |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
2 |
\documentclass[presentation]{beamer} |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
3 |
\usepackage[latin1]{inputenc} |
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
4 |
\usepackage[T1]{fontenc} |
278
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
5 |
\usepackage{fixltx2e} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
6 |
\usepackage{graphicx} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
7 |
\usepackage{longtable} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
8 |
\usepackage{float} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
9 |
\usepackage{wrapfig} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
10 |
\usepackage{soul} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
11 |
\usepackage{textcomp} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
12 |
\usepackage{marvosym} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
13 |
\usepackage{wasysym} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
14 |
\usepackage{latexsym} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
15 |
\usepackage{amssymb} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
16 |
\usepackage{hyperref} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
17 |
\tolerance=1000 |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
18 |
\usepackage[english]{babel} \usepackage{ae,aecompl} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
19 |
\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
20 |
\usepackage{listings} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
21 |
\lstset{language=Python, basicstyle=\ttfamily\bfseries, |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
22 |
commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen}, |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
23 |
showstringspaces=false, keywordstyle=\color{blue}\bfseries} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
24 |
\providecommand{\alert}[1]{\textbf{#1}} |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
25 |
|
278
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
26 |
\title{Loops} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
27 |
\author{FOSSEE} |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
28 |
\date{} |
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
29 |
|
278
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
30 |
\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent} |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
31 |
\begin{document} |
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
32 |
|
278
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
33 |
\maketitle |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
34 |
|
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
35 |
|
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
36 |
|
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
37 |
|
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
38 |
|
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
39 |
|
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
40 |
|
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
41 |
|
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
42 |
|
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
43 |
\begin{frame} |
278
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
44 |
\frametitle{Outline} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
45 |
\label{sec-1} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
46 |
|
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
47 |
\begin{itemize} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
48 |
\item Loop while a condition is true. |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
49 |
\item Iterate over a sequence |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
50 |
\item Breaking out of loops. |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
51 |
\item Skipping iterations. |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
52 |
\end{itemize} |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
53 |
\end{frame} |
278
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
54 |
\begin{frame} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
55 |
\frametitle{Question 1} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
56 |
\label{sec-2} |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
57 |
|
278
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
58 |
Write a \texttt{while} loop to print the squares of all the even |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
59 |
numbers below 10. |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
60 |
\end{frame} |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
61 |
\begin{frame}[fragile] |
278
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
62 |
\frametitle{Solution 1} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
63 |
\label{sec-3} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
64 |
|
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
65 |
\lstset{language=Python} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
66 |
\begin{lstlisting} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
67 |
In []: i = 2 |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
68 |
|
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
69 |
In []: while i<10: |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
70 |
....: print i*i |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
71 |
....: i += 2 |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
72 |
\end{lstlisting} |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
73 |
\end{frame} |
278
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
74 |
\begin{frame} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
75 |
\frametitle{Question 2} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
76 |
\label{sec-4} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
77 |
|
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
78 |
Write a \texttt{for} loop to print the squares of all the even numbers |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
79 |
below 10. |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
80 |
\end{frame} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
81 |
\begin{frame}[fragile] |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
82 |
\frametitle{Solution 2} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
83 |
\label{sec-5} |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
84 |
|
278
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
85 |
\lstset{language=Python} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
86 |
\begin{lstlisting} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
87 |
In []: for n in range(2, 10, 2): |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
88 |
....: print n*n |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
89 |
\end{lstlisting} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
90 |
\end{frame} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
91 |
\begin{frame} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
92 |
\frametitle{Question 3} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
93 |
\label{sec-6} |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
94 |
|
278
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
95 |
Using the \texttt{continue} keyword modify the \texttt{for} loop to print the |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
96 |
squares of even numbers below 10, to print the squares of only |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
97 |
multiples of 4. (Do not modify the range function call.) |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
98 |
\end{frame} |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
99 |
\begin{frame}[fragile] |
278
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
100 |
\frametitle{Solution 3} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
101 |
\label{sec-7} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
102 |
|
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
103 |
\lstset{language=Python} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
104 |
\begin{lstlisting} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
105 |
for n in range(2, 10, 2): |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
106 |
if n%4: |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
107 |
continue |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
108 |
print n*n |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
109 |
\end{lstlisting} |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
110 |
\end{frame} |
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
111 |
\begin{frame} |
278
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
112 |
\frametitle{Summary} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
113 |
\label{sec-8} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
114 |
|
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
115 |
You should now be able to -- |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
116 |
\begin{itemize} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
117 |
\item use the \texttt{for} loop |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
118 |
\item use the \texttt{while} loop |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
119 |
\item Use \texttt{break}, \texttt{continue} and \texttt{pass} statements |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
120 |
\end{itemize} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
121 |
\end{frame} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
122 |
\begin{frame} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
123 |
\frametitle{Thank you!} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
124 |
\label{sec-9} |
461a68dbefb1
Slides for loops LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
125 |
|
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
126 |
\begin{block}{} |
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
127 |
\begin{center} |
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
128 |
This spoken tutorial has been produced by the |
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
129 |
\textcolor{blue}{FOSSEE} team, which is funded by the |
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
130 |
\end{center} |
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
131 |
\begin{center} |
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
132 |
\textcolor{blue}{National Mission on Education through \\ |
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
133 |
Information \& Communication Technology \\ |
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
134 |
MHRD, Govt. of India}. |
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
135 |
\end{center} |
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
136 |
\end{block} |
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
137 |
\end{frame} |
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
138 |
|
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
139 |
\end{document} |