diff options
author | Prabhu Ramachandran | 2017-11-17 18:32:29 +0530 |
---|---|---|
committer | Prabhu Ramachandran | 2017-11-17 18:32:29 +0530 |
commit | 3b7ed43d8d159470654351c31a52f9edeaeaa60c (patch) | |
tree | d817f82e2e55780fab21f2d586c499d240120900 /advanced_python | |
parent | 5f87e0ae8e4460dc8b5c6649b011a3b382228504 (diff) | |
download | python-workshops-3b7ed43d8d159470654351c31a52f9edeaeaa60c.tar.gz python-workshops-3b7ed43d8d159470654351c31a52f9edeaeaa60c.tar.bz2 python-workshops-3b7ed43d8d159470654351c31a52f9edeaeaa60c.zip |
Fix some silly mistakes.
Diffstat (limited to 'advanced_python')
-rw-r--r-- | advanced_python/closures.tex | 10 | ||||
-rw-r--r-- | advanced_python/practice_functions.tex | 8 |
2 files changed, 9 insertions, 9 deletions
diff --git a/advanced_python/closures.tex b/advanced_python/closures.tex index 267a94a..f3571ef 100644 --- a/advanced_python/closures.tex +++ b/advanced_python/closures.tex @@ -33,11 +33,11 @@ In []: def sqr(x): In []: def sum(func, n): ...: result = 0 ...: for i in range(n): - ...: result += func(n) + ...: result += func(i) ...: return result In []: sum(sqr, 5) -Out[]: 125 +Out[]: 30 \end{lstlisting} \end{frame} @@ -74,8 +74,8 @@ Out[]: 40.0 \frametitle{Closures ...} \begin{lstlisting} -In []: twice = mul(3.0) -In []: twice(20) +In []: thrice = mul(3.0) +In []: thrice(20) Out[]: 60.0 \end{lstlisting} \end{frame} @@ -93,7 +93,7 @@ Out[]: 60.0 \begin{frame}[fragile] - \frametitle{Higher-order functions} + \frametitle{Summary: Higher-order functions} \begin{itemize} \item Functions that manipulate functions \item Passing a function as an argument diff --git a/advanced_python/practice_functions.tex b/advanced_python/practice_functions.tex index 9664171..ce7c9d6 100644 --- a/advanced_python/practice_functions.tex +++ b/advanced_python/practice_functions.tex @@ -128,13 +128,13 @@ def nkw(**kw): \end{block} \begin{lstlisting} -In []: nkw(x=1, y=2) +In []: kwname(x=1, y=2) Out[]: ['x', 'y'] -In []: nkw() +In []: kwname() Out[]: [] -In []: nkw(z=1, a=2) +In []: kwname(z=1, a=2) Out[]: ['a', 'z'] \end{lstlisting} \end{frame} @@ -143,7 +143,7 @@ Out[]: ['a', 'z'] \begin{frame}[plain, fragile] \frametitle{Solution} \begin{lstlisting} -def nkw(**kw): +def kwname(**kw): return sorted(kw.keys()) \end{lstlisting} \end{frame} |