summaryrefslogtreecommitdiff
path: root/basic_python
diff options
context:
space:
mode:
authorPrabhu Ramachandran2017-02-20 18:26:38 +0530
committerPrabhu Ramachandran2017-02-20 18:26:38 +0530
commit3abe78ca1ffbdbaed9e9a25e97bed5d609962835 (patch)
treec963754d37678fed4d813f0cabce0bd92301c9d5 /basic_python
parentb1115371efd7edd4c536c1f5de1154acd1aec8d1 (diff)
downloadpython-workshops-3abe78ca1ffbdbaed9e9a25e97bed5d609962835.tar.gz
python-workshops-3abe78ca1ffbdbaed9e9a25e97bed5d609962835.tar.bz2
python-workshops-3abe78ca1ffbdbaed9e9a25e97bed5d609962835.zip
Fix some issues with the slides.
Diffstat (limited to 'basic_python')
-rw-r--r--basic_python/files.tex19
-rw-r--r--basic_python/practice_functions.tex4
2 files changed, 14 insertions, 9 deletions
diff --git a/basic_python/files.tex b/basic_python/files.tex
index 3646c51..14ee6f6 100644
--- a/basic_python/files.tex
+++ b/basic_python/files.tex
@@ -10,7 +10,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title page
-\title[Functions]{Python language: reading/writing files}
+\title[Files]{Python language: reading/writing files}
\author[FOSSEE Team] {The FOSSEE Group}
@@ -48,7 +48,7 @@
\end{frame}
\begin{frame}[fragile]
- \frametitle{Reading the whole file}
+ \frametitle{Reading the whole file}
\begin{lstlisting}
In []: pend = f.read()
In []: print(pend)
@@ -65,6 +65,12 @@
\item \texttt{pend} is a string variable
\item We can split it at the newline characters into a list of
strings
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Closing the file}
+ \begin{itemize}
\item Close the file, when done; Also, if you want to read again
\end{itemize}
\begin{lstlisting}
@@ -73,6 +79,7 @@
\end{lstlisting}
\end{frame}
+
\begin{frame}[fragile]
\frametitle{Reading line-by-line}
\begin{lstlisting}
@@ -159,7 +166,7 @@ In []: line.split()
\begin{itemize}
\item Original string is split on white-space
\item Returns a list of strings
- \item It can be given an argument to split on that argrument
+ \item It can be given an argument to split on that argument
\end{itemize}
\begin{lstlisting}
r = "A;01;JOSE R;083;042;47;AA;72;244;;;"
@@ -190,13 +197,10 @@ r.split(';')
\end{itemize}
\begin{lstlisting}
In []: mark_str = "1.25"
- In []: mark = int(mark_str)
+ In []: mark = float(mark_str)
In []: type(mark_str)
In []: type(mark)
\end{lstlisting}
- \begin{itemize}
- \item \texttt{strip} is returning a new string
- \end{itemize}
\end{frame}
\begin{frame}[fragile, plain]
@@ -246,6 +250,7 @@ for line in open("sslc1.txt"):
\begin{frame}[fragile, plain]
\frametitle{File parsing -- debugging}
+ \small
\begin{lstlisting}
math_B = [] # empty list to store marks
for i, line in enumerate(open("sslc1.txt")):
diff --git a/basic_python/practice_functions.tex b/basic_python/practice_functions.tex
index f412c71..d71168c 100644
--- a/basic_python/practice_functions.tex
+++ b/basic_python/practice_functions.tex
@@ -269,7 +269,7 @@ Out[]: ['i', 'am', 'batman']
\begin{frame}[plain,fragile]
\frametitle{Exercise: returning a function}
\begin{enumerate}
- \item Define a function called \typ{power2()} which takes a single argument
+ \item Define a function called \typ{power2()} which takes no argument
\item It should return a function which takes a single argument \typ{x} but
returns $2^x$
\end{enumerate}
@@ -278,7 +278,7 @@ Out[]: ['i', 'am', 'batman']
In []: f = power2()
In []: f(2)
Out[]: 4
- In []: power(2)(4)
+ In []: power2()(4)
Out[]: 16
\end{lstlisting}
\end{frame}