1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1 % Created 2010-11-10 Wed 10:46 |
2 %Tutorial slides on Python. |
2 \documentclass[presentation]{beamer} |
3 % |
3 \usepackage[latin1]{inputenc} |
4 % Author: FOSSEE |
4 \usepackage[T1]{fontenc} |
5 % Copyright (c) 2009, FOSSEE, IIT Bombay |
5 \usepackage{fixltx2e} |
6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
6 \usepackage{graphicx} |
|
7 \usepackage{longtable} |
|
8 \usepackage{float} |
|
9 \usepackage{wrapfig} |
|
10 \usepackage{soul} |
|
11 \usepackage{textcomp} |
|
12 \usepackage{marvosym} |
|
13 \usepackage{wasysym} |
|
14 \usepackage{latexsym} |
|
15 \usepackage{amssymb} |
|
16 \usepackage{hyperref} |
|
17 \tolerance=1000 |
|
18 \usepackage[english]{babel} \usepackage{ae,aecompl} |
|
19 \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet} |
|
20 \usepackage{listings} |
|
21 \lstset{language=Python, basicstyle=\ttfamily\bfseries, |
|
22 commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen}, |
|
23 showstringspaces=false, keywordstyle=\color{blue}\bfseries} |
|
24 \providecommand{\alert}[1]{\textbf{#1}} |
7 |
25 |
8 \documentclass[14pt,compress]{beamer} |
26 \title{} |
9 %\documentclass[draft]{beamer} |
27 \author{FOSSEE} |
10 %\documentclass[compress,handout]{beamer} |
|
11 %\usepackage{pgfpages} |
|
12 %\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm] |
|
13 |
|
14 % Modified from: generic-ornate-15min-45min.de.tex |
|
15 \mode<presentation> |
|
16 { |
|
17 \usetheme{Warsaw} |
|
18 \useoutertheme{infolines} |
|
19 \setbeamercovered{transparent} |
|
20 } |
|
21 |
|
22 \usepackage[english]{babel} |
|
23 \usepackage[latin1]{inputenc} |
|
24 %\usepackage{times} |
|
25 \usepackage[T1]{fontenc} |
|
26 |
|
27 \usepackage{ae,aecompl} |
|
28 \usepackage{mathpazo,courier,euler} |
|
29 \usepackage[scaled=.95]{helvet} |
|
30 |
|
31 \definecolor{darkgreen}{rgb}{0,0.5,0} |
|
32 |
|
33 \usepackage{listings} |
|
34 \lstset{language=Python, |
|
35 basicstyle=\ttfamily\bfseries, |
|
36 commentstyle=\color{red}\itshape, |
|
37 stringstyle=\color{darkgreen}, |
|
38 showstringspaces=false, |
|
39 keywordstyle=\color{blue}\bfseries} |
|
40 |
|
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
42 % Macros |
|
43 \setbeamercolor{emphbar}{bg=blue!20, fg=black} |
|
44 \newcommand{\emphbar}[1] |
|
45 {\begin{beamercolorbox}[rounded=true]{emphbar} |
|
46 {#1} |
|
47 \end{beamercolorbox} |
|
48 } |
|
49 \newcounter{time} |
|
50 \setcounter{time}{0} |
|
51 \newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}} |
|
52 |
|
53 \newcommand{\typ}[1]{\lstinline{#1}} |
|
54 |
|
55 \newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} } |
|
56 |
|
57 % Title page |
|
58 \title{Your Title Here} |
|
59 |
|
60 \author[FOSSEE] {FOSSEE} |
|
61 |
|
62 \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} |
|
63 \date{} |
28 \date{} |
64 |
29 |
65 % DOCUMENT STARTS |
30 \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent} |
66 \begin{document} |
31 \begin{document} |
67 |
32 |
68 \begin{frame} |
|
69 \maketitle |
|
70 \end{frame} |
|
71 |
33 |
72 \begin{frame}[fragile] |
|
73 \frametitle{Outline} |
|
74 \begin{itemize} |
|
75 \item |
|
76 \end{itemize} |
|
77 \end{frame} |
|
78 |
34 |
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
80 %% All other slides here. %% |
|
81 %% The same slides will be used in a classroom setting. %% |
|
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
83 |
35 |
84 \begin{frame}[fragile] |
36 |
85 \frametitle{Summary} |
37 |
86 \begin{itemize} |
38 |
87 \item |
39 |
88 \end{itemize} |
40 |
89 \end{frame} |
41 |
90 |
42 |
91 \begin{frame} |
43 \begin{frame} |
92 \frametitle{Thank you!} |
44 \frametitle{Outline} |
|
45 \label{sec-1} |
|
46 \begin{itemize} |
|
47 |
|
48 \item Defining strings\\ |
|
49 \label{sec-1_1}% |
|
50 \item Concatenation\\ |
|
51 \label{sec-1_2}% |
|
52 \item Accessing individual elements\\ |
|
53 \label{sec-1_3}% |
|
54 \item Immutability of strings\\ |
|
55 \label{sec-1_4}% |
|
56 \end{itemize} % ends low level |
|
57 \end{frame} |
|
58 \begin{frame} |
|
59 \frametitle{Question 1} |
|
60 \label{sec-2} |
|
61 |
|
62 Obtain the string \texttt{\%\% -------------------- \%\%} (20 hyphens) without |
|
63 typing out all the twenty hyphens. |
|
64 \end{frame} |
|
65 \begin{frame}[fragile] |
|
66 \frametitle{Solution 1} |
|
67 \label{sec-3} |
|
68 |
|
69 \lstset{language=Python} |
|
70 \begin{lstlisting} |
|
71 s = "%% " + "-"*20 + " %%" |
|
72 \end{lstlisting} |
|
73 \end{frame} |
|
74 \begin{frame}[fragile] |
|
75 \frametitle{Question 2} |
|
76 \label{sec-4} |
|
77 |
|
78 Given a string, \texttt{s} which is \texttt{Hello World} , what is the output of:: |
|
79 \lstset{language=Python} |
|
80 \begin{lstlisting} |
|
81 s[-5] |
|
82 s[-10] |
|
83 s[-15] |
|
84 \end{lstlisting} |
|
85 \end{frame} |
|
86 \begin{frame}[fragile] |
|
87 \frametitle{Solution 2} |
|
88 \label{sec-5} |
|
89 |
|
90 \lstset{language=Python} |
|
91 \begin{lstlisting} |
|
92 'W' |
|
93 'e' |
|
94 IndexError |
|
95 \end{lstlisting} |
|
96 \end{frame} |
|
97 \begin{frame} |
|
98 \frametitle{Summary} |
|
99 \label{sec-6} |
|
100 |
|
101 In this tutorial we have learnt |
|
102 \begin{itemize} |
|
103 \item How to define strings |
|
104 \item Different ways of defining a string |
|
105 \item String concatenation and repetition |
|
106 \item Accessing individual elements of the string |
|
107 \item Immutability of strings |
|
108 \end{itemize} |
|
109 |
|
110 |
|
111 \end{frame} |
|
112 \begin{frame} |
|
113 \frametitle{Thank you!} |
|
114 \label{sec-7} |
|
115 |
93 \begin{block}{} |
116 \begin{block}{} |
94 \begin{center} |
117 \begin{center} |
95 This spoken tutorial has been produced by the |
118 This spoken tutorial has been produced by the |
96 \textcolor{blue}{FOSSEE} team, which is funded by the |
119 \textcolor{blue}{FOSSEE} team, which is funded by the |
97 \end{center} |
120 \end{center} |