day2/session1.tex
author Puneeth Chaganti <punchagan@fossee.in>
Fri, 10 Dec 2010 00:04:46 +0530
branchscipyin2010
changeset 449 49e10e9fc660
parent 420 5e408de16a14
permissions -rw-r--r--
Fixed day2/session1.tex.
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
%
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
     4
% Author: FOSSEE 
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
     5
% Copyright (c) 2009, FOSSEE, IIT Bombay
135
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}
239
8953675dc056 Added slide numbers.
Puneeth Chaganti <punchagan@fossee.in>
parents: 227
diff changeset
    18
  \useoutertheme{infolines}
135
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
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
    54
\newcommand{\typ}[1]{\textbf{\texttt{{#1}}}}
297
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
    55
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    56
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    57
\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
    58
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    59
%%% 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
    60
% \usepackage{color}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    61
% \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
    62
% % 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
    63
% \usepackage{listings}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    64
% \lstset{
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    65
%    language=Python,
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    66
%    basicstyle=\small\ttfamily,
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    67
%    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
    68
%    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
    69
%    showstringspaces=false,
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    70
%    breaklines=true,
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    71
%    postbreak = \space\dots
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    76
% Title page
250
760d5679834e Fixed typos and hanging words in Session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 239
diff changeset
    77
\title[Basic Python]{Python language: Basics}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    78
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    79
\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
    80
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    81
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
    82
\date[] {SciPy.in 2010, Tutorials}
135
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
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    85
%\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
    86
%\logo{\pgfuseimage{iitmlogo}}
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
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    89
%% 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
    90
%% 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
    91
\AtBeginSubsection[]
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    92
{
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    93
  \begin{frame}<beamer>
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    94
    \frametitle{Outline}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    95
    \tableofcontents[currentsection,currentsubsection]
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    96
  \end{frame}
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
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
    99
\AtBeginSection[]
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   100
{
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   101
  \begin{frame}<beamer>
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   102
    \frametitle{Outline}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   103
    \tableofcontents[currentsection,currentsubsection]
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   104
  \end{frame}
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
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   107
% 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
   108
% the following command: 
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   109
%\beamerdefaultoverlayspecification{<+->}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   110
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   111
%\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
   112
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   113
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   114
% DOCUMENT STARTS
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   115
\begin{document}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   116
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   117
\begin{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   118
  \titlepage
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   119
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   120
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   121
\begin{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   122
  \frametitle{Outline}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   123
  \tableofcontents
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   124
  % 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
   125
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   126
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   127
\section{Data types}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   128
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   129
\begin{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   130
  \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
   131
  \begin{itemize}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   132
    \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
   133
    \item Strings
297
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   134
    \item Booleans
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   135
  \end{itemize}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   136
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   137
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   138
\subsection{Numbers}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   139
\begin{frame}[fragile]
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   140
  \frametitle{Numbers}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   141
  \begin{itemize}
297
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   142
    \item \kwrd{int}\\ whole number, no matter what the size!
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   143
  \begin{lstlisting}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   144
In []: a = 13
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   145
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   146
In []: b = 99999999999999999999
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   147
  \end{lstlisting}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   148
    \item \kwrd{float}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   149
  \begin{lstlisting}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   150
In []: p = 3.141592
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   151
  \end{lstlisting}
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   152
    \item \kwrd{complex}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   153
  \begin{lstlisting}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   154
In []: c = 3+4j
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   155
  \end{lstlisting}
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   156
  \end{itemize}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   157
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   158
297
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   159
\subsection{Booleans}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   160
\begin{frame}[fragile]
297
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   161
  \frametitle{Booleans}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   162
  \begin{lstlisting}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   163
In []: t = True
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   164
387
5e485a5d8ac4 Minor corrections post SVCE.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 385
diff changeset
   165
In []: F = not t
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   166
387
5e485a5d8ac4 Minor corrections post SVCE.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 385
diff changeset
   167
In []: F or t
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   168
Out[]: True
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   169
387
5e485a5d8ac4 Minor corrections post SVCE.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 385
diff changeset
   170
In []: F and t
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   171
Out[]: False
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   172
  \end{lstlisting}
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   173
%%  \inctime{5}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   174
\end{frame}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   175
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   176
\begin{frame}[fragile]
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   177
  \frametitle{( )  for precedence}
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   178
  \begin{lstlisting}
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   179
In []: a = False
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   180
In []: b = True
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   181
In []: c = True
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   182
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   183
In []: (a and b) or c
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   184
Out[]: True
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   185
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   186
In []: a and (b or c)
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   187
Out[]: False
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   188
  \end{lstlisting}
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   189
%%  \inctime{5}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   190
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   191
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   192
\subsection{Strings}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   193
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   194
\begin{frame}[fragile]
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   195
\frametitle{Strings}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   196
Anything within ``quotes'' is a string!
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   197
\begin{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   198
' This is a string '  
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   199
" This too! "
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   200
""" This one too! """
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   201
''' And one more! '''
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   202
\end{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   203
\end{frame}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   204
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   205
\begin{frame}[fragile]
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   206
\frametitle{Strings}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   207
Why so many?
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   208
\begin{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   209
' "Do or do not.  No try." said Yoda.'  
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   210
" ' is a mighty lonely quote."
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   211
\end{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   212
The triple quoted ones can span multiple lines!
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   213
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   214
\begin{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   215
""" The quick brown
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   216
fox jumped over
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   217
    the lazy dingbat. 
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   218
"""
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   219
\end{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   220
\end{frame}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   221
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   222
\begin{frame}[fragile]
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   223
  \frametitle{Strings}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   224
  \begin{lstlisting}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   225
In []: w = "hello"
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   226
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   227
In []: print w[0], w[1], w[-1]
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   228
297
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   229
In []: len(w)
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   230
Out[]: 5
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   231
  \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   232
\end{frame}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   233
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   234
\begin{frame}[fragile]
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   235
  \frametitle{Strings \ldots}
297
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   236
  \emphbar{Strings are immutable}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   237
  \begin{lstlisting}
297
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   238
In []: w[0] = 'H' 
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   239
  \end{lstlisting}
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   240
  \pause
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   241
  \begin{lstlisting}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   242
--------------------------------------------
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   243
TypeError  Traceback (most recent call last)
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   244
384
9f9fddf7e37c MNIT Jaipur changes.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 380
diff changeset
   245
<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
   246
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   247
TypeError: 'str' object does not
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   248
         support item assignment
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   249
  \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   250
\end{frame}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   251
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   252
\section{Operators}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   253
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   254
\begin{frame}[fragile]
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   255
  \frametitle{Arithmetic operators}
297
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   256
  \small
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   257
  \begin{lstlisting}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   258
In []: 1786 % 12
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   259
Out[]: 10
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   260
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   261
In []: 45 % 2
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   262
Out[]: 1
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   263
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   264
In []: 864675 % 10
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   265
Out[]: 5
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   266
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   267
In []: 3124 * 126789
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   268
Out[]: 396088836
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   269
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   270
In []: big = 1234567891234567890 ** 3
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   271
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   272
In []: verybig = big * big * big * big
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   273
  \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   274
\end{frame}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   275
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   276
\begin{frame}[fragile]
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   277
  \frametitle{Arithmetic operators}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   278
  \begin{lstlisting}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   279
In []: 17 / 2
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   280
Out[]: 8
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   281
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   282
In []: 17 / 2.0
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   283
Out[]: 8.5
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   284
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   285
In []: 17.0 / 2
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   286
Out[]: 8.5
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   287
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   288
In []: 17.0 / 8.5
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   289
Out[]: 2.0
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   290
  \end{lstlisting}
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   291
\end{frame}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   292
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   293
\begin{frame}[fragile]
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   294
\frametitle{Arithmetic operators}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   295
  \begin{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   296
In []: c = 3+4j
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   297
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   298
In []: abs(c)
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   299
Out[]: 5.0
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   300
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   301
In []: c.imag
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   302
Out[]: 4.0
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   303
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   304
In []: c.real
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   305
Out[]: 3.0
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   306
  \end{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   307
\end{frame}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   308
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   309
\begin{frame}[fragile]
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   310
  \frametitle{Arithmetic operators}
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   311
  \begin{lstlisting}
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   312
In []: a = 7546
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   313
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   314
In []: a += 1
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   315
In []: a
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   316
Out[]: 7547
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   317
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   318
In []: a -= 5
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   319
In []: a
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   320
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   321
In []: a *= 2
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   322
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   323
In []: a /= 5
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   324
  \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   325
\end{frame}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   326
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   327
\begin{frame}[fragile]
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   328
  \frametitle{String operations}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   329
  \begin{lstlisting}
297
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   330
In []: s = 'Hello'
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   331
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   332
In []: p = 'World'
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   333
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   334
In []: s + p 
297
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   335
Out[]: 'HelloWorld'
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   336
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   337
In []: s * 4
297
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   338
Out[]: 'HelloHelloHelloHello'
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   339
  \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   340
\end{frame}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   341
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   342
\begin{frame}[fragile]
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   343
  \frametitle{String operations \ldots}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   344
  \begin{lstlisting}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   345
In []: s * s
297
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   346
  \end{lstlisting}
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   347
  \pause
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   348
  \begin{lstlisting}
216
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
TypeError  Traceback (most recent call last)
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   351
380
669b72283b55 Updated after Day 2 at GRDCS
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 378
diff changeset
   352
<ipython console> in <module>()
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   353
297
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   354
TypeError: can`t multiply sequence by
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   355
                non-int of type `str`
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   356
  \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   357
\end{frame}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   358
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   359
\begin{frame}[fragile]
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   360
  \frametitle{String methods}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   361
  \begin{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   362
In []: a = 'Hello World'
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   363
In []: a.startswith('Hell')
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   364
Out[]: True
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   365
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   366
In []: a.endswith('ld')
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   367
Out[]: True
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   368
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   369
In []: a.upper()
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   370
Out[]: 'HELLO WORLD'
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   371
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   372
In []: a.lower()
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   373
Out[]: 'hello world'
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   374
  \end{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   375
\end{frame}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   376
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   377
\begin{frame}[fragile]
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   378
\frametitle{Strings: \typ{split} \& \typ{join}}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   379
  \begin{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   380
In []: chars = 'a b c'
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   381
In []: chars.split()
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   382
Out[]: ['a', 'b', 'c']
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   383
In []: ' '.join(['a', 'b', 'c'])
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   384
Out[]: 'a b c'
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   385
  \end{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   386
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   387
  \begin{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   388
In []: alpha = ', '.join(['a', 'b', 'c'])
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   389
In []: alpha
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   390
Out[]: 'a, b, c'
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   391
In []: alpha.split(', ')
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   392
Out[]: ['a', 'b', 'c']
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   393
  \end{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   394
\end{frame}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   395
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   396
\begin{frame}[fragile]
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   397
\frametitle{String formatting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   398
  \begin{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   399
In []: x, y = 1, 1.234
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   400
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   401
In []: 'x is %s, y is %s' %(x, y)
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   402
Out[]: 'x is 1, y is 1.234'
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   403
  \end{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   404
  \begin{itemize}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   405
    \item \emph{\%d}, \emph{\%f} etc. available
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   406
  \end{itemize}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   407
  \emphbar{\url{http://docs.python.org/library/stdtypes.html}}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   408
%%  \inctime{10}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   409
\end{frame}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   410
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   411
\begin{frame}[fragile]
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   412
  \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
   413
  \begin{lstlisting}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   414
In []: p, z, n = 1, 0, -1
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   415
In []: p == n
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   416
Out[]: False
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   417
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   418
In []: p >= n
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   419
Out[]: True
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   420
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   421
In []: n < z < p
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   422
Out[]: True
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   423
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   424
In []: p + n != z
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   425
Out[]: False
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   426
  \end{lstlisting}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   427
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   428
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   429
\begin{frame}[fragile]
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   430
  \frametitle{Built-ins}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   431
  \begin{lstlisting}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   432
In []: int(17 / 2.0)
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   433
Out[]: 8
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   434
297
a835affb1447 Added final changes to all day 2 slides for Calicut workshop.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 288
diff changeset
   435
In []: float(17 / 2)
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   436
Out[]: 8.0
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   437
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   438
In []: str(17 / 2.0)
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   439
Out[]: '8.5'
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   440
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   441
In []: round( 7.5 )
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   442
Out[]: 8.0
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   443
  \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   444
\end{frame}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   445
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   446
\begin{frame}[fragile]
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   447
  \frametitle{Odds and ends}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   448
  \begin{itemize}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   449
    \item Case sensitive
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   450
    \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
   451
      \begin{lstlisting}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   452
In []: a = 1
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   453
In []: a = 1.1
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   454
In []: a = "Now I am a string!"
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   455
      \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   456
    \item Comments:
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   457
      \begin{lstlisting}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   458
In []: a = 1  # In-line comments
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   459
In []: # A comment line.
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   460
In []: a = "# Not a comment!"
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   461
      \end{lstlisting}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   462
  \end{itemize}
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   463
%%  \inctime{15}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   464
\end{frame}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   465
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   466
\section{Simple IO}
250
760d5679834e Fixed typos and hanging words in Session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 239
diff changeset
   467
\begin{frame}[fragile]
760d5679834e Fixed typos and hanging words in Session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 239
diff changeset
   468
  \frametitle{Simple IO: Console Input}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   469
  \small
250
760d5679834e Fixed typos and hanging words in Session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 239
diff changeset
   470
  \begin{itemize}
760d5679834e Fixed typos and hanging words in Session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 239
diff changeset
   471
    \item raw\_input() waits for user input.
760d5679834e Fixed typos and hanging words in Session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 239
diff changeset
   472
      \begin{lstlisting}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   473
In []: a = raw_input()
250
760d5679834e Fixed typos and hanging words in Session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 239
diff changeset
   474
5
760d5679834e Fixed typos and hanging words in Session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 239
diff changeset
   475
359
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 344
diff changeset
   476
In []: a
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 344
diff changeset
   477
Out[]: '5'
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 344
diff changeset
   478
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   479
In []: a = raw_input('Enter a value: ')
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   480
Enter a value: 5
250
760d5679834e Fixed typos and hanging words in Session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 239
diff changeset
   481
      \end{lstlisting}
760d5679834e Fixed typos and hanging words in Session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 239
diff changeset
   482
    \item Prompt string is optional.
420
5e408de16a14 Minor edits.
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   483
    \item All keystrokes are strings!
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   484
    \item \typ{int()} converts string to int.
250
760d5679834e Fixed typos and hanging words in Session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 239
diff changeset
   485
  \end{itemize}
760d5679834e Fixed typos and hanging words in Session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 239
diff changeset
   486
\end{frame}
760d5679834e Fixed typos and hanging words in Session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 239
diff changeset
   487
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   488
\begin{frame}[fragile]
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   489
  \frametitle{Simple IO: Console output}
250
760d5679834e Fixed typos and hanging words in Session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 239
diff changeset
   490
  \begin{itemize}
359
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 344
diff changeset
   491
    \item \typ{print} is straight forward
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 344
diff changeset
   492
    \item Put the following code snippet in a file \typ{hello1.py}
250
760d5679834e Fixed typos and hanging words in Session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 239
diff changeset
   493
  \end{itemize}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   494
  \begin{lstlisting}
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   495
print "Hello"
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   496
print "World"
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   497
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   498
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   499
In []: %run -i hello1.py
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   500
Hello
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   501
World
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   502
  \end{lstlisting}
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   503
\end{frame}
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   504
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   505
\begin{frame}[fragile]
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   506
  \frametitle{Simple IO: Console output \ldots}
359
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 344
diff changeset
   507
Put the following code snippet in a file \typ{hello2.py}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   508
  \begin{lstlisting}
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   509
print "Hello",
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   510
print "World"
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   511
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   512
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   513
In []: %run -i hello2.py
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   514
Hello World
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   515
  \end{lstlisting}
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   516
359
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 344
diff changeset
   517
\emphbar{Note the distinction between \typ{print x} and \typ{print x,}}
216
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   518
\end{frame}
c6704d4a18bd Removed multiplication of list with * operator.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 204
diff changeset
   519
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   520
\section{Control flow}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   521
\begin{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   522
  \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
   523
  \begin{itemize}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   524
  \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
   525
  \item \kwrd{while}: looping
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   526
  \item \kwrd{for}: iterating
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   527
  \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
   528
  \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
   529
  \end{itemize}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   530
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   531
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   532
\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
   533
\begin{frame}[fragile]
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   534
  \frametitle{\typ{if...elif...else} example}
373
f04eca8b2f3d Commits from NIT DGP and IITK
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 366
diff changeset
   535
Type the following code in an editor \& save as \alert{ladder.py}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   536
  \small
227
a6705e2dfdc6 Complete session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 217
diff changeset
   537
  \begin{lstlisting}
359
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 344
diff changeset
   538
x = int(raw_input("Enter an integer:"))
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 344
diff changeset
   539
if x < 0:
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 344
diff changeset
   540
    print 'Be positive!'
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 344
diff changeset
   541
elif x == 0:
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 344
diff changeset
   542
    print 'Zero'
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 344
diff changeset
   543
elif x == 1:
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 344
diff changeset
   544
    print 'Single'
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 344
diff changeset
   545
else:
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 344
diff changeset
   546
    print 'More'
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   547
227
a6705e2dfdc6 Complete session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 217
diff changeset
   548
  \end{lstlisting}
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   549
%%  \inctime{10}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   550
\end{frame}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   551
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   552
\section{Control flow}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   553
\subsection{Basic Looping}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   554
\begin{frame}[fragile]
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   555
  \frametitle{\typ{while}}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   556
\begin{block}{Example: Fibonacci series}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   557
  Sum of previous two elements defines the next
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   558
\end{block}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   559
  \begin{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   560
In []: a, b = 0, 1
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   561
In []: while b < 10:
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   562
  ...:     print b,
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   563
  ...:     a, b = b, a + b
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   564
  ...:
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   565
  ...:
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   566
\end{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   567
\typ{1 1 2 3 5 8}\\
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   568
\end{frame}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   569
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   570
\begin{frame}[fragile]
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   571
\frametitle{\typ{range()}}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   572
\kwrd{range([start,] stop[, step])}\\
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   573
\begin{itemize}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   574
  \item \typ{range()} returns a list of integers
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   575
  \item The \typ{start} and the \typ{step} arguments are optional
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   576
  \item \typ{stop} is not included in the list
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   577
\end{itemize}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   578
\vspace*{.5in}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   579
\begin{block}{Documentation convention}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   580
  \begin{itemize}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   581
    \item \alert{Anything within \typ{[]} is optional}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   582
    \item Nothing to do with Python.
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   583
  \end{itemize}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   584
\end{block}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   585
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   586
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   587
\begin{frame}[fragile]
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   588
  \frametitle{\typ{for} \ldots \typ{range()}}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   589
Example: print squares of first \typ{5} numbers
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   590
  \begin{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   591
In []: for i in range(5):
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   592
 ....:     print i, i * i
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   593
 ....:
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   594
 ....:
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   595
0 0
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   596
1 1
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   597
2 4
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   598
3 9
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   599
4 16
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   600
\end{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   601
\end{frame}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   602
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   603
\begin{frame}[fragile]
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   604
  \frametitle{\typ{for} \ldots \typ{range()}}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   605
Example: print squares of odd numbers from 3 to 9
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   606
  \begin{lstlisting}
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   607
In []: for i in range(3, 10, 2):
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   608
 ....:     print i, i * i
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   609
 ....:
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   610
 ....:
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   611
3 9
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   612
5 25
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   613
7 49
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   614
9 81
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   615
\end{lstlisting}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   616
%% \inctime{5}
227
a6705e2dfdc6 Complete session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 217
diff changeset
   617
\end{frame}
a6705e2dfdc6 Complete session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 217
diff changeset
   618
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   619
\subsection{Exercises}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   620
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   621
\begin{frame}{Problem 1.1: \emph{Armstrong} numbers}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   622
  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$\\
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   623
For example, $153 = 1^3 + 5^3 + 3^3$\\
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   624
\vspace*{0.2in}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   625
\end{frame}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   626
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   627
\begin{frame}{Problem 1.2: Collatz sequence}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   628
\begin{enumerate}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   629
  \item Start with an arbitrary (positive) integer. 
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   630
  \item If the number is even, divide by 2; if the number is odd, multiply by 3 and add 1.
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   631
  \item Repeat the procedure with the new number.
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   632
  \item It appears that for all starting values there is a cycle of 4, 2, 1 at which the procedure loops.
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   633
\end{enumerate}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   634
    Write a program that accepts the starting value and prints out the Collatz sequence.
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   635
%% \inctime{5}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   636
\end{frame}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   637
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   638
227
a6705e2dfdc6 Complete session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 217
diff changeset
   639
\begin{frame}[fragile]
a6705e2dfdc6 Complete session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 217
diff changeset
   640
  \frametitle{What did we learn?}
a6705e2dfdc6 Complete session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 217
diff changeset
   641
  \begin{itemize}
288
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   642
    \item Data types: int, float, complex, boolean, string
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   643
    \item Operators: +, -, *, /, \%, **, +=, -=, *=, /=, >, <, <=, >=, ==, !=, a < b < c
c4e25269a86c Reorganized slides.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 250
diff changeset
   644
    \item Simple IO: \kwrd{raw\_input} and \kwrd{print}
449
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   645
    \item Conditionals: \kwrd{if elif else}
49e10e9fc660 Fixed day2/session1.tex.
Puneeth Chaganti <punchagan@fossee.in>
parents: 420
diff changeset
   646
    \item Looping: \kwrd{while} \& \kwrd{for} 
227
a6705e2dfdc6 Complete session 1 day 2.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 217
diff changeset
   647
  \end{itemize}
135
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   648
\end{frame}
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   649
a5da7607ab14 Added Session 1, Day 2 - "Formal approach to Python" slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff changeset
   650
\end{document}
344
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   651
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   652
%% Questions for Quiz %%
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   653
%% ------------------ %%
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   654
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   655
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   656
\begin{frame}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   657
\frametitle{\incqno }
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   658
  What is the largest integer value that can be represented natively by Python?
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   659
\end{frame}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   660
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   661
\begin{frame}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   662
\frametitle{\incqno }
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   663
  What is the result of 17.0 / 2?
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   664
\end{frame}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   665
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   666
\begin{frame}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   667
\frametitle{\incqno }
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   668
  Which of the following is not a type in Python?
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   669
  \begin{enumerate}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   670
    \item int
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   671
    \item float
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   672
    \item char
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   673
    \item string
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   674
  \end{enumerate}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   675
\end{frame}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   676
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   677
\begin{frame}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   678
\frametitle{\incqno }
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   679
How do you create a complex number with real part 2 and imaginary part
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   680
0.5.
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   681
\end{frame}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   682
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   683
\begin{frame}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   684
\frametitle{\incqno }
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   685
  What is the difference between \kwrd{print} \emph{x} and \kwrd{print} \emph{x,} ?
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   686
\end{frame}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   687
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   688
\begin{frame}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   689
\frametitle{\incqno }
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   690
  What does '*' * 40 produce?
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   691
\end{frame}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   692
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   693
\begin{frame}[fragile]
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   694
\frametitle{\incqno }
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   695
    What is the output of:
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   696
    \begin{lstlisting}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   697
In []: ', '.join(['a', 'b', 'c'])
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   698
    \end{lstlisting}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   699
\end{frame}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   700
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   701
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   702
\begin{frame}[fragile]
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   703
    \frametitle{\incqno}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   704
  \begin{lstlisting}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   705
In []: 47 % 3 
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   706
  \end{lstlisting}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   707
  What is the output?
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   708
\end{frame}
19754ed6050f Moved all day2 quiz questions to end of day2-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   709