summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnoop Jacob Thomas2010-10-28 12:16:47 +0530
committerAnoop Jacob Thomas2010-10-28 12:16:47 +0530
commita8fef20e35bebe7ac39d764760ab60f302f53755 (patch)
tree94bbe5076b79474ea58713783f801f7967cfaeea
parent041aa6dbcdefbdd38240bced152e1be68a6962a8 (diff)
downloadst-scripts-a8fef20e35bebe7ac39d764760ab60f302f53755.tar.gz
st-scripts-a8fef20e35bebe7ac39d764760ab60f302f53755.tar.bz2
st-scripts-a8fef20e35bebe7ac39d764760ab60f302f53755.zip
reviewed advanced features of functions script.
-rw-r--r--advanced-features-functions/script.rst45
-rw-r--r--advanced-features-functions/slides.tex18
-rw-r--r--manipulating-strings/slides.tex23
-rw-r--r--progress.org4
4 files changed, 64 insertions, 26 deletions
diff --git a/advanced-features-functions/script.rst b/advanced-features-functions/script.rst
index 5b7b3e2..0abae54 100644
--- a/advanced-features-functions/script.rst
+++ b/advanced-features-functions/script.rst
@@ -17,7 +17,7 @@
.. #. getting started with functions
.. Author : Puneeth
- Internal Reviewer :
+ Internal Reviewer : Anoop Jacob Thomas<anoop@fossee.in>
External Reviewer :
Checklist OK? : <put date stamp here, if OK> [2010-10-05]
@@ -57,7 +57,15 @@ calls it with two arguments. By observing the output, we can guess
that the first one is equivalent to call with the second argument
being 0. 0 is the default value of the argument.
+.. #[[Anoop: It will be good if we show ``round??`` and tell them the
+ optional argument ndigits, or it could be given as an
+ exercise(solved) asking them to find the name of the argument in
+ the function round]]
+
{{{ show a slide with examples of functions showing default values }}}
+
+.. #[[Anoop: I think the slide is not there]]
+
::
s.strip() # strips on spaces.
@@ -101,12 +109,17 @@ the output. "World" is the default value for the argument ``name``.
Following is an (are) exercise(s) that you must do.
+{{{ switch to next slide, containing problem statement of
+ question 1 }}}
+
%%1%% Redefine the function ``welcome``, by interchanging it's
arguments. Place the ``name`` argument with it's default value of
"World" before the ``greet`` argument.
Please, pause the video here. Do the exercise and then continue.
+{{{ switch to next slide, containing the solution to problem 1 }}}
+
::
def welcome(name="World", greet):
@@ -116,25 +129,37 @@ We get an error that reads ``SyntaxError: non-default argument follows
default argument``. When defining a function all the argument with
default values should come at the end.
+.. #[[Anoop: In the slide, "when defining a function all the default
+ arguments must be defined at the end" has to be emphasized"]]
+
Following is an exercise that you must do.
+{{{ switch to next slide, containing the problem statement of
+ question 2 }}}
+
%%2%% See the definition of linspace using ``?`` and observe how all
the arguments with default values are towards the end.
Please, pause the video here. Do the exercise and then continue.
+{{{ switch to next slide, containing solution to problem 2 }}}
+
::
linspace?
Following is an exercise that you must do.
+{{{ switch to next slide, problem statement }}}
+
%%3%% Redefine the function ``welcome`` with a default value of
"Hello" to the ``greet`` argument. Then, call the function without any
arguments.
Please, pause the video here. Do the exercise and then continue.
+{{{ switch to next slide, solution }}}
+
::
def welcome(greet="Hello", name="World"):
@@ -147,6 +172,9 @@ Please, pause the video here. Do the exercise and then continue.
Let us now learn what keyword arguments are.
{{{ show a slide with examples using keyword arguments. }}}
+
+.. #[[Anoop: slide is missing]]
+
::
legend(['sin(2y)'], loc = 'center')
@@ -157,6 +185,14 @@ Let us now learn what keyword arguments are.
pie(science.values(), labels = science.keys())
+.. #[[Anoop: I think it will better to introduce keyword arguments as
+ keyword/named arguments, as the keyword term was quite confusing
+ for me, so can be for someone who already know certain
+ jargon's/concepts, also it would be good to tell them that these
+ are different from keywords in programming languages, explicit is
+ better than implicit, and probably you could also tell them that
+ from now on we will refer to it as just keyword arguments]]
+
When you are calling functions in Python, you don't need to remember
the order in which to pass the arguments. Instead, you can use the
name of the argument to pass it a value. This slide shows a few
@@ -199,6 +235,8 @@ arguments.
{{{ switch to a slide showing variety of functions with uses }}}
+.. #[[Anoop: slide missing]]
+
Before defining a function of your own, make sure that you check the
standard library, for a similar function. Python is popularly called a
"Batteries included" language, for the huge library that comes along
@@ -214,6 +252,8 @@ with it.
{{{ switch to slide showing classes of functions in pylab, scipy }}}
+.. #[[Anoop: slide missing]]
+
Apart from the standard library there are other libraries like ``pylab``,
``scipy``, etc which have a huge collection of functions for scientific
purposes.
@@ -227,6 +267,9 @@ purposes.
{{{ Show summary slide }}}
+.. #[[Anoop: add range of functions available in python standard
+ library]]
+
That brings us to the end of this tutorial. In this tutorial we have
learnt how to use functions with default values and keyword
arguments. We also looked at the range of functions available in the
diff --git a/advanced-features-functions/slides.tex b/advanced-features-functions/slides.tex
index 311be4f..9e1d66f 100644
--- a/advanced-features-functions/slides.tex
+++ b/advanced-features-functions/slides.tex
@@ -1,4 +1,4 @@
-% Created 2010-10-11 Mon 00:34
+% Created 2010-10-28 Thu 11:37
\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
@@ -8,6 +8,7 @@
\usepackage{float}
\usepackage{wrapfig}
\usepackage{soul}
+\usepackage{t1enc}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
@@ -62,11 +63,10 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries}
\frametitle{Solution 1}
\label{sec-3}
-\lstset{language=Python}
-\begin{lstlisting}
+\begin{verbatim}
def welcome(name="World", greet):
print greet, name
-\end{lstlisting}
+\end{verbatim}
We get an error that reads \texttt{SyntaxError: non-default argument follows default argument}. When defining a function all the
argument with default values should come at the end.
\end{frame}
@@ -81,10 +81,9 @@ def welcome(name="World", greet):
\frametitle{Solution 2}
\label{sec-5}
-\lstset{language=Python}
-\begin{lstlisting}
+\begin{verbatim}
linspace?
-\end{lstlisting}
+\end{verbatim}
\end{frame}
\begin{frame}
\frametitle{Question 3}
@@ -98,13 +97,12 @@ linspace?
\frametitle{Solution 3}
\label{sec-7}
-\lstset{language=Python}
-\begin{lstlisting}
+\begin{verbatim}
def welcome(greet="Hello", name="World"):
print greet, name
welcome()
-\end{lstlisting}
+\end{verbatim}
\end{frame}
\begin{frame}
\frametitle{Summary}
diff --git a/manipulating-strings/slides.tex b/manipulating-strings/slides.tex
index 02e2b7e..ed0317b 100644
--- a/manipulating-strings/slides.tex
+++ b/manipulating-strings/slides.tex
@@ -1,4 +1,4 @@
-% Created 2010-10-11 Mon 11:27
+% Created 2010-10-28 Thu 11:35
\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
@@ -8,6 +8,7 @@
\usepackage{float}
\usepackage{wrapfig}
\usepackage{soul}
+\usepackage{t1enc}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
@@ -63,10 +64,9 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries}
\frametitle{Solution 1}
\label{sec-3}
-\lstset{language=Python}
-\begin{lstlisting}
+\begin{verbatim}
In []: s[1:-1]
-\end{lstlisting}
+\end{verbatim}
\end{frame}
\begin{frame}
\frametitle{Question 2}
@@ -80,11 +80,10 @@ In []: s[1:-1]
\frametitle{Solution 2}
\label{sec-5}
-\lstset{language=Python}
-\begin{lstlisting}
+\begin{verbatim}
In []: s in week
In []: s.lower()[:3] in week
-\end{lstlisting}
+\end{verbatim}
\end{frame}
\begin{frame}
\frametitle{Question 3}
@@ -98,11 +97,10 @@ In []: s.lower()[:3] in week
\frametitle{Solution 3}
\label{sec-7}
-\lstset{language=Python}
-\begin{lstlisting}
+\begin{verbatim}
email.replace('[dot], '.')
print email
-\end{lstlisting}
+\end{verbatim}
\end{frame}
\begin{frame}
\frametitle{Question 4}
@@ -115,10 +113,9 @@ print email
\frametitle{Solution 4}
\label{sec-9}
-\lstset{language=Python}
-\begin{lstlisting}
+\begin{verbatim}
email_str = email_str.replace(",", ";")
-\end{lstlisting}
+\end{verbatim}
\end{frame}
\begin{frame}
\frametitle{Summary}
diff --git a/progress.org b/progress.org
index 2ba0ad6..c2a173b 100644
--- a/progress.org
+++ b/progress.org
@@ -40,14 +40,14 @@
| 6.5 LO: | Assessment | 3 | Anoop | | |
|---------+----------------------------------------+-------+----------+---------------------------------------+-----------|
| 7.1 LO: | manipulating lists | 3 | Madhu | | |
-| 7.2 LO: | manipulating strings | 2 | Punch | Anoop(Pending) | |
+| 7.2 LO: | manipulating strings | 2 | Punch | Amit(Done) | |
| 7.3 LO: | getting started with tuples | 2 | Nishanth | | |
| 7.4 LO: | dictionaries | 2 | Anoop | Punch (Done) | |
| 7.5 LO: | sets | 2 | Nishanth | | |
| 7.6 LO: | Assessment | 3 | Amit | | |
|---------+----------------------------------------+-------+----------+---------------------------------------+-----------|
| 8.1 LO: | getting started with functions | 3 | Nishanth | | |
-| 8.2 LO: | advanced features of functions | 3 | Punch | Anoop(Pending) | |
+| 8.2 LO: | advanced features of functions | 3 | Punch | Anoop(Done) | |
| 8.3 LO: | using python modules | 3 | Anoop | Punch (Done) | |
| 8.4 LO: | writing python scripts | 2 | Nishanth | | |
| 8.5 LO: | testing and debugging | 2 | Amit | | |