summaryrefslogtreecommitdiff
path: root/basic_python
diff options
context:
space:
mode:
authorPrabhu Ramachandran2017-02-22 14:21:40 +0530
committerPrabhu Ramachandran2017-02-22 14:21:40 +0530
commit309565f772c6a69480e28ce7246e611564964696 (patch)
tree17560f3a44c02c0b622baa78504566234f6679a4 /basic_python
parent10058532c29188637409eed7643626eff53bdc7c (diff)
downloadpython-workshops-309565f772c6a69480e28ce7246e611564964696.tar.gz
python-workshops-309565f772c6a69480e28ce7246e611564964696.tar.bz2
python-workshops-309565f772c6a69480e28ce7246e611564964696.zip
Fix issues in slides.
Diffstat (limited to 'basic_python')
-rw-r--r--basic_python/exceptions.tex39
-rw-r--r--basic_python/practice_files_exc.tex13
2 files changed, 33 insertions, 19 deletions
diff --git a/basic_python/exceptions.tex b/basic_python/exceptions.tex
index 766dc98..8b9eb46 100644
--- a/basic_python/exceptions.tex
+++ b/basic_python/exceptions.tex
@@ -164,15 +164,17 @@ while True:
\begin{frame}[fragile]
\frametitle{Catching multiple exceptions}
+ \small
\begin{lstlisting}
-data = input()
-try:
- x = int(data.split(',')[1])
- break
-except IndexError:
- print('Input at least 2 values.')
-except ValueError:
- print("Invalid input, try again...")
+while True:
+ try:
+ data = input()
+ x = int(data.split(',')[1])
+ break
+ except IndexError:
+ print('Input at least 2 values.')
+ except ValueError:
+ print("Invalid input, try again...")
\end{lstlisting}
\end{frame}
@@ -184,7 +186,6 @@ except ValueError:
data = input()
try:
x = int(data.split(',')[1])
- break
except (ValueError, IndexError):
print("Invalid input ...")
@@ -193,15 +194,17 @@ except (ValueError, IndexError):
\begin{frame}[fragile]
\frametitle{\typ{try, except, else}}
+ \small
\begin{lstlisting}
-data = input()
-try:
- x = int(data.split(',')[1])
- break
-except (ValueError, IndexError):
- print("Invalid input ...")
-else:
- print('All is well!')
+while True:
+ try:
+ data = input()
+ x = int(data.split(',')[1])
+ except (ValueError, IndexError):
+ print("Invalid input ...")
+ else:
+ print('All is well!')
+ break
\end{lstlisting}
\end{frame}
@@ -239,7 +242,7 @@ while True:
except ValueError:
print("Invalid number, try again...")
finally:
- print "All good!"
+ print("All good!")
\end{lstlisting}
\normalsize
diff --git a/basic_python/practice_files_exc.tex b/basic_python/practice_files_exc.tex
index 4a7cdfc..1eda602 100644
--- a/basic_python/practice_files_exc.tex
+++ b/basic_python/practice_files_exc.tex
@@ -176,7 +176,7 @@ def largest(f):
\begin{frame}[plain, fragile]
\frametitle{Exercise: raising exceptions}
\begin{enumerate}
- \item Write a function \typ{func} which takes a single integer argument
+ \item Write a function \typ{func} which takes a single integer argument \typ{x}
\item If \typ{x} is not a positive integer raise a \typ{ValueError}
\item If \typ{x} is not an integer type raise a \typ{TypeError}
\end{enumerate}
@@ -196,6 +196,17 @@ def largest(f):
\end{frame}
\begin{frame}
+ \frametitle{What next?}
+ \begin{itemize}
+ \item Only covered the very basics
+ \item More advanced topics remain
+ \item Read the official Python tutorial:
+ \url{docs.python.org/tutorial/}
+ \end{itemize}
+\end{frame}
+
+
+\begin{frame}
\centering
\Huge