getting-started-files/slides.tex
author amit
Tue, 26 Oct 2010 15:44:09 +0530
changeset 349 9ced58c5c3b6
parent 345 d82151cc11f5
permissions -rw-r--r--
Added long answer type problems in all scripts
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
345
d82151cc11f5 Reviewed script getting started with files.
Anoop Jacob Thomas<anoop@fossee.in>
parents: 274
diff changeset
     1
% Created 2010-10-21 Thu 14:35
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     2
\documentclass[presentation]{beamer}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     3
\usepackage[latin1]{inputenc}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     4
\usepackage[T1]{fontenc}
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     5
\usepackage{fixltx2e}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     6
\usepackage{graphicx}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     7
\usepackage{longtable}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     8
\usepackage{float}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
     9
\usepackage{wrapfig}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    10
\usepackage{soul}
345
d82151cc11f5 Reviewed script getting started with files.
Anoop Jacob Thomas<anoop@fossee.in>
parents: 274
diff changeset
    11
\usepackage{t1enc}
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    12
\usepackage{textcomp}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    13
\usepackage{marvosym}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    14
\usepackage{wasysym}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    15
\usepackage{latexsym}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    16
\usepackage{amssymb}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    17
\usepackage{hyperref}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    18
\tolerance=1000
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    19
\usepackage[english]{babel} \usepackage{ae,aecompl}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    20
\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    21
\usepackage{listings}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    22
\lstset{language=Python, basicstyle=\ttfamily\bfseries,
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    23
commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    24
showstringspaces=false, keywordstyle=\color{blue}\bfseries}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    25
\providecommand{\alert}[1]{\textbf{#1}}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    26
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    27
\title{Getting started with files}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    28
\author{FOSSEE}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    29
\date{}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    30
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    31
\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    32
\begin{document}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    33
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    34
\maketitle
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    35
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    36
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    37
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    38
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    39
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    40
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    41
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    42
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    43
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    44
\begin{frame}
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    45
\frametitle{Outline}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    46
\label{sec-1}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    47
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    48
\begin{itemize}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    49
\item Opening and reading contents of a file
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    50
\item Closing open files
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    51
\item Reading all the contents of the file at once
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    52
\item Reading files line by line
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    53
\end{itemize}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    54
\end{frame}
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    55
\begin{frame}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    56
\frametitle{Question 1}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    57
\label{sec-2}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    58
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    59
  Split the variable into a list, \texttt{pend\_list}, of the lines in the
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    60
  file. Hint, use the tab command to see what methods the string
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    61
  variable has.
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    62
\end{frame}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    63
\begin{frame}[fragile]
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    64
\frametitle{Solution 1}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    65
\label{sec-3}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    66
345
d82151cc11f5 Reviewed script getting started with files.
Anoop Jacob Thomas<anoop@fossee.in>
parents: 274
diff changeset
    67
\begin{verbatim}
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    68
In []: pend_list = pend.splitlines()
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    69
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    70
In []: pend_list
345
d82151cc11f5 Reviewed script getting started with files.
Anoop Jacob Thomas<anoop@fossee.in>
parents: 274
diff changeset
    71
\end{verbatim}
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    72
\end{frame}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    73
\begin{frame}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    74
\frametitle{Question 2}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    75
\label{sec-4}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    76
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    77
  Re-open the file \texttt{pendulum.txt} with \texttt{f} as the file object.
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    78
\end{frame}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    79
\begin{frame}[fragile]
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    80
\frametitle{Solution 2}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    81
\label{sec-5}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    82
345
d82151cc11f5 Reviewed script getting started with files.
Anoop Jacob Thomas<anoop@fossee.in>
parents: 274
diff changeset
    83
\begin{verbatim}
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    84
In []:   f = open('/home/fossee/pendulum.txt')
345
d82151cc11f5 Reviewed script getting started with files.
Anoop Jacob Thomas<anoop@fossee.in>
parents: 274
diff changeset
    85
\end{verbatim}
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    86
\end{frame}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    87
\begin{frame}
274
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    88
\frametitle{Summary}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    89
\label{sec-6}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    90
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    91
\begin{itemize}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    92
\item Opening a file using \texttt{open} function
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    93
\item Reading all the contents of the file at once using \texttt{read()} method
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    94
\item Closing open files using the \texttt{close} method
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    95
\item Reading files line by line by iterating using a \texttt{for} loop
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    96
\end{itemize}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    97
\end{frame}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    98
\begin{frame}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
    99
\frametitle{Thank you!}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   100
\label{sec-7}
1f8921b59ff0 Slides for getting started with files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents: 217
diff changeset
   101
217
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   102
  \begin{block}{}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   103
  \begin{center}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   104
  This spoken tutorial has been produced by the
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   105
  \textcolor{blue}{FOSSEE} team, which is funded by the 
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   106
  \end{center}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   107
  \begin{center}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   108
    \textcolor{blue}{National Mission on Education through \\
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   109
      Information \& Communication Technology \\ 
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   110
      MHRD, Govt. of India}.
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   111
  \end{center}  
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   112
  \end{block}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   113
\end{frame}
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   114
b595f90016c5 Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   115
\end{document}