day2/session1.tex
author Shantanu <shantanu@fossee.in>
Wed, 28 Oct 2009 15:17:39 +0530
changeset 220 15306dad3b81
parent 217 2833f0b51adc
child 227 a6705e2dfdc6
permissions -rw-r--r--
Corrections to day1 Session1, day2 Session 3 and 4.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
     1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
     2
%Tutorial slides on Python.
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
     3
%
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
     4
% Author: Prabhu Ramachandran <prabhu at aero.iitb.ac.in>
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
     5
% Copyright (c) 2005-2009, Prabhu Ramachandran
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
     6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
     7
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
     8
\documentclass[14pt,compress]{beamer}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
     9
%\documentclass[draft]{beamer}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    10
%\documentclass[compress,handout]{beamer}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    11
%\usepackage{pgfpages} 
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    12
%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    13
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    14
% Modified from: generic-ornate-15min-45min.de.tex
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    15
\mode<presentation>
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    16
{
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    17
  \usetheme{Warsaw}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    18
  \useoutertheme{split}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    19
  \setbeamercovered{transparent}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    20
}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    21
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    22
\usepackage[english]{babel}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    23
\usepackage[latin1]{inputenc}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    24
%\usepackage{times}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    25
\usepackage[T1]{fontenc}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    26
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    27
% Taken from Fernando's slides.
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    28
\usepackage{ae,aecompl}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    29
\usepackage{mathpazo,courier,euler}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    30
\usepackage[scaled=.95]{helvet}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    31
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    32
\definecolor{darkgreen}{rgb}{0,0.5,0}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    33
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    34
\usepackage{listings}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    35
\lstset{language=Python,
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    36
    basicstyle=\ttfamily\bfseries,
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    37
    commentstyle=\color{red}\itshape,
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    38
  stringstyle=\color{darkgreen},
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    39
  showstringspaces=false,
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    40
  keywordstyle=\color{blue}\bfseries}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    41
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    42
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    43
% Macros
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    44
\setbeamercolor{emphbar}{bg=blue!20, fg=black}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    45
\newcommand{\emphbar}[1]
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    46
{\begin{beamercolorbox}[rounded=true]{emphbar} 
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    47
      {#1}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    48
 \end{beamercolorbox}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    49
}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    50
\newcounter{time}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    51
\setcounter{time}{0}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    52
\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    53
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    54
\newcommand{\typ}[1]{\texttt{#1}}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    55
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    56
\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}}  }
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    57
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    58
%%% This is from Fernando's setup.
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    59
% \usepackage{color}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    60
% \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    61
% % Use and configure listings package for nicely formatted code
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    62
% \usepackage{listings}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    63
% \lstset{
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    64
%    language=Python,
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    65
%    basicstyle=\small\ttfamily,
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    66
%    commentstyle=\ttfamily\color{blue},
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    67
%    stringstyle=\ttfamily\color{orange},
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    68
%    showstringspaces=false,
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    69
%    breaklines=true,
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    70
%    postbreak = \space\dots
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    71
% }
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    72
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    73
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    74
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    75
% Title page
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    76
\title[Basic Python]{Python:\\A formal approach}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    77
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    78
\author[FOSSEE Team] {The FOSSEE Group}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    79
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    80
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    81
\date[] {1, November 2009\\Day 2, Session 1}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    82
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    83
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    84
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    85
%\logo{\pgfuseimage{iitmlogo}}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    86
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    87
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    88
%% Delete this, if you do not want the table of contents to pop up at
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    89
%% the beginning of each subsection:
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    90
\AtBeginSubsection[]
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    91
{
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    92
  \begin{frame}<beamer>
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    93
    \frametitle{Outline}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    94
    \tableofcontents[currentsection,currentsubsection]
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    95
  \end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    96
}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    97
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    98
\AtBeginSection[]
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    99
{
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   100
  \begin{frame}<beamer>
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   101
    \frametitle{Outline}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   102
    \tableofcontents[currentsection,currentsubsection]
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   103
  \end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   104
}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   105
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   106
% If you wish to uncover everything in a step-wise fashion, uncomment
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   107
% the following command: 
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   108
%\beamerdefaultoverlayspecification{<+->}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   109
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   110
%\includeonlyframes{current,current1,current2,current3,current4,current5,current6}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   111
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   112
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   113
% DOCUMENT STARTS
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   114
\begin{document}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   115
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   116
\begin{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   117
  \titlepage
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   118
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   119
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   120
\begin{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   121
  \frametitle{Outline}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   122
  \tableofcontents
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   123
  % You might wish to add the option [pausesections]
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   124
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   125
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   126
\section{Data types}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   127
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   128
\begin{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   129
  \frametitle{Primitive Data types}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   130
  \begin{itemize}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   131
    \item Numbers: float, int, complex
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   132
    \item Strings
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   133
    \item Boolean
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   134
  \end{itemize}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   135
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   136
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   137
\subsection{Numbers}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   138
\begin{frame}[fragile]
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   139
  \frametitle{Numbers}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   140
  \begin{itemize}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   141
    \item \kwrd{int}\\ Any whole number is an \kwrd{int}, no matter what the size!
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   142
  \begin{lstlisting}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   143
In [1]: a = 13
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   144
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   145
In [2]: b = 99999999999999999999
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   146
  \end{lstlisting}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   147
    \item \kwrd{float}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   148
  \begin{lstlisting}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   149
In [3]: fl = 3.141592
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   150
  \end{lstlisting}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   151
  \end{itemize}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   152
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   153
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   154
\begin{frame}[fragile]
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   155
\frametitle{Complex numbers}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   156
  \begin{lstlisting}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   157
In [1]: cplx = 3+4j
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   158
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   159
In [2]: abs(cplx)
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   160
Out[2]: 5.0
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   161
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   162
In [3]: cplx.imag
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   163
Out[3]: 4.0
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   164
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   165
In [4]: cplx.real
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   166
Out[4]: 3.0
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   167
  \end{lstlisting}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   168
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   169
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   170
\subsection{Boolean}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   171
\begin{frame}[fragile]
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   172
  \frametitle{Boolean}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   173
  \begin{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   174
In [1]: t = True
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   175
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   176
In [2]: f = not t
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   177
Out[2]: False
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   178
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   179
In [3]: f or t
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   180
Out[3]: True
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   181
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   182
In [4]: f and t
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   183
Out[4]: False
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   184
  \end{lstlisting}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   185
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   186
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   187
\subsection{Strings}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   188
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   189
\begin{frame}[fragile]
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   190
  \frametitle{Strings}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   191
Strings were introduced previously, let us now look at them in a little more detail.
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   192
  \begin{lstlisting}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   193
In [1]: w = "hello"
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   194
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   195
In [2]: print w[0] + w[2] + w[-1]
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   196
Out[2]: hlo
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   197
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   198
In [3]: len(w) # guess what
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   199
Out[3]: 5
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   200
  \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   201
\end{frame}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   202
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   203
\begin{frame}[fragile]
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   204
  \frametitle{Strings \ldots}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   205
  \begin{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   206
In [1]: w[0] = 'H' # Can't do that!
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   207
--------------------------------------------
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   208
TypeError  Traceback (most recent call last)
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   209
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   210
/<ipython console> in <module>()
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   211
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   212
TypeError: 'str' object does not
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   213
         support item assignment
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   214
  \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   215
\end{frame}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   216
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   217
\begin{frame}[fragile]
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   218
  \frametitle{String methods}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   219
  \begin{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   220
In [1]: a = 'Hello World'
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   221
In [2]: a.startswith('Hell')
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   222
Out[2]: True
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   223
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   224
In [3]: a.endswith('ld')
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   225
Out[3]: True
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   226
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   227
In [4]: a.upper()
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   228
Out[4]: 'HELLO WORLD'
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   229
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   230
In [5]: a.lower()
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   231
Out[5]: 'hello world'
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   232
  \end{lstlisting}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   233
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   234
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   235
\begin{frame}[fragile]
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   236
\frametitle{Still with strings}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   237
  \begin{itemize}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   238
    \item We saw split() yesterday
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   239
    \item join() is the opposite of split()
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   240
  \end{itemize}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   241
  \begin{lstlisting}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   242
In [1]: ''.join(['a', 'b', 'c'])
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   243
Out[1]: 'abc'
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   244
  \end{lstlisting}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   245
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   246
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   247
\begin{frame}[fragile]
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   248
\frametitle{String formatting}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   249
  \begin{lstlisting}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   250
In [1]: x, y = 1, 1.234
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   251
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   252
In [2]: 'x is %s, y is %s' %(x, y)
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   253
Out[2]: 'x is 1, y is 1.234'
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   254
  \end{lstlisting}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   255
\emphbar{
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   256
\url{http://docs.python.org/library/stdtypes.html}\\
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   257
}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   258
\inctime{10}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   259
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   260
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   261
\section{Operators}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   262
\begin{frame}[fragile]
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   263
  \frametitle{Arithematic operators}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   264
  \begin{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   265
In [1]: 1786 % 12
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   266
Out[1]: 10
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   267
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   268
In [2]: 3124 * 126789
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   269
Out[2]: 396088836
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   270
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   271
In [3]: a = 3124 * 126789
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   272
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   273
In [4]: big = 1234567891234567890 ** 3
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   274
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   275
In [5]: verybig = big * big * big * big
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   276
  \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   277
\end{frame}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   278
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   279
\begin{frame}[fragile]
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   280
  \frametitle{Arithematic operators \ldots}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   281
  \begin{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   282
In [1]: 17/2
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   283
Out[1]: 8
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   284
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   285
In [2]: 17/2.0
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   286
Out[2]: 8.5
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   287
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   288
In [3]: 17.0/2
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   289
Out[3]: 8.5
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   290
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   291
In [4]: 17.0/8.5
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   292
Out[4]: 2.0
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   293
  \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   294
\end{frame}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   295
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   296
\begin{frame}[fragile]
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   297
  \frametitle{String operations}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   298
  \begin{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   299
In [1]: s = 'Hello '
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   300
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   301
In [2]: p = 'World'
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   302
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   303
In [3]: s + p 
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   304
Out[3]: 'Hello World'
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   305
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   306
In [4]: s * 12 
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   307
Out[4]: 'Hello Hello Hello Hello ...'
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   308
  \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   309
\end{frame}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   310
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   311
\begin{frame}[fragile]
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   312
  \frametitle{String operations \ldots}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   313
  \begin{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   314
In [1]: s * s
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   315
--------------------------------------------
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   316
TypeError  Traceback (most recent call last)
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   317
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   318
/<ipython console> in <module>()
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   319
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   320
TypeError: can't multiply sequence by
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   321
                non-int of type 'str'
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   322
  \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   323
\end{frame}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   324
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   325
\begin{frame}[fragile]
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   326
  \frametitle{Relational and logical operators}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   327
  \begin{lstlisting}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   328
In [1]: pos, zer, neg = 1, 0, -1
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   329
In [2]: pos == neg
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   330
Out[2]: False
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   331
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   332
In [3]: pos >= neg
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   333
Out[3]: True
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   334
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   335
In [4]: neg < zer < pos
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   336
Out[4]: True
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   337
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   338
In [5]: pos + neg != zer
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   339
Out[5]: False
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   340
  \end{lstlisting}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   341
\inctime{5}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   342
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   343
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   344
\begin{frame}[fragile]
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   345
  \frametitle{Built-ins}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   346
  \begin{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   347
In [1]: int(17/2.0)
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   348
Out[1]: 8
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   349
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   350
In [2]: float(17/2)  # Recall
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   351
Out[2]: 8.0
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   352
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   353
In [3]: str(17/2.0)
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   354
Out[3]: '8.5'
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   355
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   356
In [4]: round( 7.5 )
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   357
Out[4]: 8.0
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   358
  \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   359
\end{frame}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   360
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   361
\begin{frame}[fragile]
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   362
  \frametitle{Odds and ends}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   363
  \begin{itemize}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   364
    \item Case sensitive
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   365
    \item Dynamically typed $\Rightarrow$ need not specify a type
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   366
      \begin{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   367
In [1]: a = 1
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   368
In [2]: a = 1.1
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   369
In [3]: a = "Now I am a string!"
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   370
      \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   371
    \item Comments:
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   372
      \begin{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   373
In [4]: a = 1  # In-line comments
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   374
In [5]: # Comment in a line to itself.
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   375
In [6]: a = "# This is not a comment!"
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   376
      \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   377
  \end{itemize}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   378
  \inctime{15}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   379
\end{frame}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   380
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   381
\begin{frame}[fragile] \frametitle{A question of good style}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   382
  \begin{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   383
    amount = 12.68
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   384
    denom = 0.05
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   385
    nCoins = round(amount/denom)
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   386
    rAmount = nCoins * denom
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   387
  \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   388
  \pause
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   389
  \begin{block}{Style Rule \#1}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   390
    Naming is 80\% of programming
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   391
  \end{block}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   392
\end{frame}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   393
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   394
\section{Simple IO}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   395
\begin{frame}{Simple IO}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   396
  \begin{block}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   397
    {Console Input}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   398
    \texttt{raw\_input()} waits for user input.\\Prompt string is optional.\\
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   399
    All keystrokes are Strings!\\\texttt{int()} converts string to int.
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   400
  \end{block}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   401
  \begin{block}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   402
    {Console output}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   403
    \texttt{print} is straight forward. Note the distinction between \texttt{print x} and \texttt{print x,}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   404
  \end{block}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   405
\end{frame}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   406
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   407
\section{Control flow}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   408
\begin{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   409
  \frametitle{Control flow constructs}  
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   410
  \begin{itemize}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   411
  \item \kwrd{if/elif/else}: branching
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   412
  \item \kwrd{while}: looping
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   413
  \item \kwrd{for}: iterating 
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   414
  \item \kwrd{break, continue}: modify loop 
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   415
  \item \kwrd{pass}: syntactic filler
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   416
  \end{itemize}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   417
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   418
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   419
\subsection{Basic Conditional flow}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   420
\begin{frame}[fragile]
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   421
  \frametitle{\typ{If...elif...else} example}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   422
\begin{lstlisting}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   423
x = int(raw_input("Enter an integer:"))
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   424
if x < 0:
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   425
     print 'Be positive!'
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   426
elif x == 0:
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   427
     print 'Zero'
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   428
elif x == 1:
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   429
     print 'Single'
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   430
else:
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   431
     print 'More'
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   432
\end{lstlisting}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   433
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   434
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   435
\subsection{Basic Looping}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   436
\begin{frame}[fragile]
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   437
  \frametitle{\typ{while}}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   438
Example: Fibonacci series
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   439
  \begin{lstlisting}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   440
# the sum of two elements
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   441
# defines the next
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   442
a, b = 0, 1
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   443
while b < 10:
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   444
    print b,
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   445
    a, b = b, a + b 
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   446
\end{lstlisting}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   447
\typ{1 1 2 3 5 8}\\  
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   448
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   449
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   450
\begin{frame}[fragile]
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   451
\frametitle{\typ{range()}}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   452
\kwrd{range([start,] stop[, step])}\\
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   453
\begin{itemize}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   454
  \item \alert {range() returns a list of integers}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   455
  \item \alert {The start and the step arguments are optional}  
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   456
\end{itemize}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   457
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   458
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   459
\begin{frame}[fragile]
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   460
  \frametitle{\typ{for} \ldots \typ{range()}}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   461
Example: print squares of first \typ{n} numbers
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   462
  \begin{lstlisting}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   463
In []: for i in range(5):
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   464
 ....:     print i, i * i
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   465
 ....:     
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   466
 ....:     
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   467
0 0
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   468
1 1
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   469
2 4
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   470
3 9
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   471
4 16
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   472
\end{lstlisting}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   473
\inctime{15}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   474
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   475
217
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   476
\subsection{Exercises}
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   477
\begin{frame}
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   478
  \frametitle{Problem set 1}
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   479
  \begin{itemize}
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   480
    \item All the problems can be\\
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   481
      solved using \kwrd{if} and \kwrd{while} 
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   482
  \end{itemize}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   483
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   484
217
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   485
\begin{frame}{Problem 1.1}
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   486
  Write a program that displays all three digit numbers that are equal to the sum of the cubes of their digits. That is, print numbers $abc$ that have the property $abc = a^3 + b^3 + c^3$\\
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   487
\vspace*{0.2in}
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   488
\emphbar{These are called $Armstrong$ numbers.}
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   489
\end{frame}
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   490
  
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   491
\begin{frame}{Problem 1.2 - Collatz sequence}
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   492
\begin{enumerate}
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   493
  \item Start with an arbitrary (positive) integer. 
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   494
  \item If the number is even, divide by 2; if the number is odd, multiply by 3 and add 1.
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   495
  \item Repeat the procedure with the new number.
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   496
  \item It appears that for all starting values there is a cycle of 4, 2, 1 at which the procedure loops.
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   497
\end{enumerate}
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   498
    Write a program that accepts the starting value and prints out the Collatz sequence.
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   499
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   500
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   501
217
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   502
\begin{frame}[fragile]{Problem 1.4}
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   503
  Write a program that prints the following pyramid on the screen. 
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   504
  \begin{lstlisting}
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   505
1
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   506
2  2
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   507
3  3  3
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   508
4  4  4  4
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   509
  \end{lstlisting}
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   510
The number of lines must be obtained from the user as input.\\
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   511
\pause
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   512
\emphbar{When can your code fail?}
2833f0b51adc Completed day 2 Session 1.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 216
diff changeset
   513
\only<2->{\inctime{20}}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   514
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   515
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   516
\end{document}