diff options
author | Jovina | 2011-07-12 12:14:01 +0530 |
---|---|---|
committer | Jovina | 2011-07-12 12:14:01 +0530 |
commit | bc1bdc9be493bada965904f7c6235aa09a082b18 (patch) | |
tree | dcd325b197e858b9f8631b58962fa7e94ed24478 /advanced_features_of_functions | |
parent | 22aae6a95dd1b330536057b051434efb2a7fbc5d (diff) | |
download | st-scripts-bc1bdc9be493bada965904f7c6235aa09a082b18.tar.gz st-scripts-bc1bdc9be493bada965904f7c6235aa09a082b18.tar.bz2 st-scripts-bc1bdc9be493bada965904f7c6235aa09a082b18.zip |
Major changes to script & slides of 'advanced features of functions'.
Diffstat (limited to 'advanced_features_of_functions')
-rw-r--r-- | advanced_features_of_functions/script.rst | 334 | ||||
-rw-r--r-- | advanced_features_of_functions/slides.org | 152 | ||||
-rw-r--r-- | advanced_features_of_functions/slides.tex | 231 |
3 files changed, 533 insertions, 184 deletions
diff --git a/advanced_features_of_functions/script.rst b/advanced_features_of_functions/script.rst index a649f93..db7a1ba 100644 --- a/advanced_features_of_functions/script.rst +++ b/advanced_features_of_functions/script.rst @@ -25,53 +25,81 @@ Script ------ -{{{ Show the slide containing title }}} +.. L1 -Welcome to the tutorial on advanced feature of functions. +{{{ Show the first slide containing title, name of the production +team along with the logo of MHRD }}} -{{{ Show the outline slide }}} +.. R1 -In this tutorial we shall be looking at specifying default arguments -to functions when defining them and calling functions using keyword -arguments. We shall also, look at some of the built-in functions -available in the standard library of Python and the scientific -computing libraries. +Hello friends and Welcome to the tutorial on 'advanced features of functions'. -{{{ switch to terminal }}} +.. L2 -Open the ipython terminal. To invoke ipython interpreter type ipython -pyab. +{{{ Show the objective slide }}} + +.. R2 + +At the end of this tutorial, you will be able to, + + 1. Assign default values to arguments, when defining functions. + #. Define and call functions with keyword arguments. + #. Learn some of the built-in functions available in Python standard + library and the scientific computing libraries. + +.. L3 + +{{{ Switch to the pre-requisite slide }}} + +.. R3 + +Before beginning this tutorial,we would suggest you to complete the +tutorial on "Getting started with functions". + +.. R4 + +Let us Start the ipython interpreter + +.. L4 + +{{{ Open the terminal }}} +:: + + ipython -pylab. + +.. R5 Let's use the ``round`` function as an example to understand what a default value of an argument means. Let's type the following expressions in the terminal. +.. L5 :: - round(2.484) + round(2.484) + + round(2.484, 2) - round(2.484, 2) +.. R6 Both the first expression and the second are calls to the ``round`` function, but the first calls it with only one argument and the second 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. +being 0. 0 . -.. #[[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]] +.. L6 -{{{ show a slide with examples of functions showing default values }}} +.. L7 -.. #[[Anoop: I think the slide is not there]] +{{{ show a slide with examples of functions showing default values }}} -:: +.. R7 s.strip() # strips on spaces. s.strip('@') # strips the string of '@' symbols. -Thus it can be said that here blank space is the default argument. +Thus it can be said that here, blank space is the default argument. plot(x, y) # plots with x vs. y using default line style. plot(x, y, 'o') # plots x vs. y with circle markers. @@ -83,114 +111,166 @@ Hence, here when third argument is not provided, it shows default line style. Hence, the default for the third argument is 50. -.. #[punch: all above content goes on to a slide] - -{{{ switch back to ipython }}} +.. R8 Let's now define a simple function that uses default arguments. We define a simple function that prints a welcome message to a person, given a greeting and his/her name. +.. L8 + +{{{ switch to terminal }} :: - def welcome(greet, name="World"): - print greet, name + def welcome(greet, name="World"): + print greet, name + +.. R9 Let us first call the function with two arguments, one for ``greet`` and other for ``name``. +.. L9 :: - welcome("Hi", "Guido") + welcome("Hi", "Guido") + +.. R10 We get the expected welcome message, "Hi Guido". Now let us call the function with just one argument "Hello". + +.. L10 :: - welcome("Hello") + welcome("Hello") + +.. R11 "Hello" is treated as the ``greet`` and we get "Hello World" as the output. "World" is the default value for the argument ``name``. -Pause the video and solve this exercise. Resume the video after you solve this. +Pause the video here, try out the following exercise and resume the video. + +.. L11 -{{{ switch to next slide, containing problem statement of - question 1 }}} +.. L12 -%%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. +{{{ Show slide with exercise 1 }}} -Please, pause the video here. Do the exercise and then continue. +.. R12 -{{{ switch to next slide, containing the solution to problem 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. +.. R13 + +Switch to the terminal for solution + +.. L13 + +{{{continue from paused state}}} +{{{ Switch to the terminal }}} :: - def welcome(name="World", greet): - print greet, name + def welcome(name="World", greet): + print greet, name + +.. R14 We get an error that reads ``SyntaxError: non-default argument follows -default argument``. When defining a function all the argument with +default argument``. + +.. L14 + +{{{ Show slide with solution 1 }}} + +.. R15 + +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"]] +Pause the video here, try out the following exercise and resume the video. + +.. L15 + +.. L16 -Pause the video and solve this exercise. Resume the video after you solve this. +{{{ Show slide with exercise 2 }}} -{{{ switch to next slide, containing the problem statement of - question 2 }}} +.. R16 -%%2%% See the definition of linspace using ``?`` and observe how all -the arguments with default values are towards the end. + See the definition of linspace using ``?`` and make a note of all + the arguments with default values are towards the end. -Please, pause the video here. Do the exercise and then continue. +.. R17 -{{{ switch to next slide, containing solution to problem 2 }}} +Switch to the terminal for solution +.. L17 + +{{{continue from paused state}}} +{{{ Switch to the terminal }}} :: - linspace? + linspace? -Pause the video and solve this exercise. Resume the video after you solve this. +.. R18 -{{{ switch to next slide, problem statement }}} +As we go on hitting the enter key, we the the number of arguments this +command has.Please read the content on your terminal. +<pause> -%%3%% Redefine the function ``welcome`` with a default value of -"Hello" to the ``greet`` argument. Then, call the function without any -arguments. +Again, Pause the video here, try out the following exercise and resume the video. + +.. L18 + +.. L19 + +{{{ Show slide with exercise 3 }}} -Please, pause the video here. Do the exercise and then continue. +.. R19 -{{{ switch to next slide, solution }}} + Redefine the function ``welcome`` with a default value of + "Hello" to the ``greet`` argument. Then, call the function without any + arguments. +.. R20 + +Switch to the terminal for solution + +.. L20 + +{{{continue from paused state}}} +{{{ Switch to the terminal }}} :: - def welcome(greet="Hello", name="World"): - print greet, name + def welcome(greet="Hello", name="World"): + print greet, name + welcome() - welcome() +.. R21 +As we can see, we get the output as ``Hello World``. Let us now learn what keyword arguments or named arguments are. We shall refer to them as keyword arguments, henceforth. -{{{ show a slide with examples using keyword arguments. }}} - -.. #[[Anoop: slide is missing]] - -:: +.. L21 - legend(['sin(2y)'], loc = 'center') +.. L22 - plot(y, sin(y), 'g', linewidth = 2) +{{{ show slide keyword arguments examples }}} - annotate('local max', xy = (1.5, 1)) + 1. legend(['sin(2y)'], loc = 'center') + #. plot(y, sin(y), 'g', linewidth = 2) + #. annotate('local max', xy = (1.5, 1)) + #. pie(science.values(), labels = science.keys()) - pie(science.values(), labels = science.keys()) +.. R22 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 @@ -198,64 +278,76 @@ name of the argument to pass it a value. This slide shows a few function calls that use keyword arguments. ``loc``, ``linewidth``, ``xy`` and ``labels`` are being called with keyword arguments. -{{{ switch to ipython terminal }}} - Let us try and understand this better using the ``welcome`` function that we have been using all along. Let us call it in different ways and observe the output to see how keyword arguments work. +.. L22 + +{{{ switch to ipython terminal }}} :: - welcome() + welcome() - welcome("Hello", "James") + welcome("Hello", "James") - welcome("Hi", name="Guido") + welcome("Hi", name="Guido") + +.. R23 When no keyword is specified, the arguments are allotted based on their position. So, "Hi" is the value of the argument ``greet`` and -name is passed the value "Guido". +name is passed the value "Guido".If we type, + +.. L23 :: - welcome(name="Guido", greet="Hey! ") + welcome(name="Guido", greet="Hey! ") + +.. R24 When keyword arguments are used, the arguments can be called in any -order. +order. And if we call our function as, +.. L24 :: - welcome(name="Guido", "Hey") + welcome(name="Guido", "Hey") -This call returns an error that reads, ``non keyword arg after keyword +.. R25 + +This call returns an error that reads, ``non-keyword arg after keyword arg``. Python expects all the keyword to be present towards the end. That brings us to the end of what we wanted to learn about ``keyword`` arguments. -{{{ switch to a slide showing variety of functions with uses }}} +.. L25 + +.. L26 -.. #[[Anoop: slide missing]] +{{{ switch to slide built-in functions }}} + +.. R26 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 with it. -:: - Math functions - abs, sin, .... + Plot functions - plot, bar, pie ... + Boolean functions - and, or, not ... -.. #[punch: Need to decide, exactly what to put here. Reviewer comments -.. welcome.] +.. L27 {{{ switch to slide showing classes of functions in pylab, scipy }}} -.. #[[Anoop: slide missing]] +.. R27 Apart from the standard library there are other libraries like ``pylab``, ``scipy``, etc which have a huge collection of functions for scientific purposes. -:: pylab plot, bar, contour, boxplot, errorbar, log, polar, quiver, semilog @@ -263,20 +355,70 @@ purposes. scipy (modules) fftpack, stats, linalg, ndimage, signal, optimize, integrate +.. L28 + {{{ Show summary slide }}} -.. #[[Anoop: add range of functions available in python standard - library]] +.. R28 -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 -Python standard library and the Scientific Computing related -packages. +This brings us to the end of this tutorial. In this tutorial, we +have learnt to, -{{{ Show the "sponsored by FOSSEE" slide }}} + 1. Define functions with default arguments. + #. Call functions using keyword arguments. + #. Use the range of functions available in the Python standard library + and the Scientific Computing related packages. -This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India +.. L30 -Hope you have enjoyed and found it useful. +{{{Show self assessment questions slide}}} + +.. R30 + +Here are some self assessment questions for you to solve + +1. All arguments of a function cannot have default values. + - True or False? + +2. The following is a valid function definition. True or False? +:: + + def seperator(count=40, char, show=False): + if show: + print char * count + return char * count + +3. When calling a function, + + - the arguments should always be in the order in which they are defined. + - the arguments can be in any order. + - only keyword arguments can be in any order, but should be called + at the beginning. + - only keyword arguments can be in any order, but should be called + at the end. + +.. L31 + +{{{solution of self assessment questions on slide}}} + +.. R31 + +And the answers, + +1. Flase.All arguments of a Python function can have default values. + +2. False. All parameters with default arguments should be + defined at the end. + +3. When calling a function,only keyword arguments can be in any order, + but should be called at the end. + +.. L32 + +{{{ Show the Thankyou slide }}} + +.. R32 + +Hope you have enjoyed this tutorial and found it useful. Thank you! + diff --git a/advanced_features_of_functions/slides.org b/advanced_features_of_functions/slides.org index fb66b6f..947b306 100644 --- a/advanced_features_of_functions/slides.org +++ b/advanced_features_of_functions/slides.org @@ -18,7 +18,7 @@ #+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen}, #+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries} -#+TITLE: Advanced features of functions +#+TITLE: #+AUTHOR: FOSSEE #+EMAIL: #+DATE: @@ -29,58 +29,136 @@ #+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t #+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc -* Outline - - Assigning default values to arguments - - Calling functions using Keyword arguments - - functions in standard library -* Question 1 - Redefine the function ~welcome~, by interchanging it's - arguments. Place the ~name~ argument with it's default value of +* +#+begin_latex +\begin{center} +\vspace{12pt} +\textcolor{blue}{\huge Advanced features of Functions} +\end{center} +\vspace{18pt} +\begin{center} +\vspace{10pt} +\includegraphics[scale=0.95]{../images/fossee-logo.png}\\ +\vspace{5pt} +\scriptsize Developed by FOSSEE Team, IIT-Bombay. \\ +\scriptsize Funded by National Mission on Education through ICT\\ +\scriptsize MHRD,Govt. of India\\ +\includegraphics[scale=0.30]{../images/iitb-logo.png}\\ +\end{center} +#+end_latex +* Objectives + At the end of this tutorial, you will be able to, + + - Assign default values to arguments, when defining functions. + - Define and call functions with keyword arguments. + - Learn some of the built-in functions available in Python standard + library and the scientific computing libraries. +* Pre-requisite +Spoken tutorial on - +- Getting started with functions +* Functions +#+begin_src Python +s.strip() # strips on spaces. +s.strip('@') # strips the string of '@' symbols. + +plot(x, y) # plots with x vs. y using default line style. +plot(x, y, 'o') # plots x vs. y with circle markers. + +linspace(0, 2*pi, 100) # returns 100 points between 0 and 2pi +linspace(0, 2*pi) # returns 50 points between 0 and 2pi +#+end_src +* Exercise 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. * Solution 1 #+begin_src python def welcome(name="World", greet): print greet, name #+end_src - We get an error that reads ~SyntaxError: non-default argument - follows default argument~. When defining a function all the + 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. -* Question 2 - See the definition of linspace using ~?~ and observe how all the +* Exercise 2 + - See the definition of linspace using ~?~ and make a note of all the arguments with default values are towards the end. -* Solution 2 - #+begin_src python - linspace? - #+end_src -* Question 3 - Redefine the function ~welcome~ with a default value of - "Hello" to the ~greet~ argument. Then, call the function without any - arguments. -* Solution 3 - #+begin_src python - def welcome(greet="Hello", name="World"): - print greet, name - - welcome() - #+end_src +* Exercise 3 + - Redefine the function ~welcome~ with a default value of + "Hello" to the ~greet~ argument. + Then, call the function without any arguments. +* Keyword arguments examples +#+begin_src Python +legend(['sin(2y)'], loc = 'center') + +plot(y, sin(y), 'g', linewidth = 2) + +annotate('local max', xy = (1.5, 1)) + +pie(science.values(), labels = science.keys()) +#+end_src +* Built-in functions +#+begin_src Python + Math functions - abs, sin, .... + + Plot functions - plot, bar, pie ... + + Boolean functions - and, or, not ... +#+end_src +* Classes of functions +#+begin_src Python +- pylab + - plot, bar, contour, boxplot, errorbar, log, polar, quiver, semilog + +- scipy (modules) + - fftpack, stats, linalg, ndimage, signal, optimize, integrate +#+end_src * Summary - You should now be able to -- - + define functions with default arguments - + call functions using keyword arguments -* Thank you! + In this tutorial, we have learnt to, + + - Define functions with default arguments. + - Call functions using keyword arguments. + - Use the range of functions available in the Python standard library + and the Scientific Computing related packages. + +* Evaluation +1. All arguments of a function cannot have default values. + - True or False? + +2. The following is a valid function definition. True or False? +#+begin_src Python +def seperator(count=40, char, show=False): + if show: + print char * count + return char * count +#+end_src +3. When calling a function, + + - the arguments should always be in the order in which they are defined. + - only keyword arguments can be in any order, but should be called + at the beginning. + - only keyword arguments can be in any order, but should be called + at the end. +* Solutions +1. False + +2. False + +3. only keyword arguments can be in any order, + but should be called at the end +* #+begin_latex \begin{block}{} \begin{center} - This spoken tutorial has been produced by the - \textcolor{blue}{FOSSEE} team, which is funded by the + \textcolor{blue}{\Large THANK YOU!} \end{center} + \end{block} +\begin{block}{} \begin{center} - \textcolor{blue}{National Mission on Education through \\ - Information \& Communication Technology \\ - MHRD, Govt. of India}. + For more Information, visit our website\\ + \url{http://fossee.in/} \end{center} \end{block} #+end_latex - diff --git a/advanced_features_of_functions/slides.tex b/advanced_features_of_functions/slides.tex index 9e1d66f..ea41b95 100644 --- a/advanced_features_of_functions/slides.tex +++ b/advanced_features_of_functions/slides.tex @@ -1,4 +1,4 @@ -% Created 2010-10-28 Thu 11:37 +% Created 2011-07-12 Tue 11:20 \documentclass[presentation]{beamer} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} @@ -8,7 +8,6 @@ \usepackage{float} \usepackage{wrapfig} \usepackage{soul} -\usepackage{t1enc} \usepackage{textcomp} \usepackage{marvosym} \usepackage{wasysym} @@ -24,14 +23,13 @@ commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen}, showstringspaces=false, keywordstyle=\color{blue}\bfseries} \providecommand{\alert}[1]{\textbf{#1}} -\title{Advanced features of functions} +\title{} \author{FOSSEE} \date{} \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent} \begin{document} -\maketitle @@ -41,94 +39,225 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries} + +\begin{frame} + +\begin{center} +\vspace{12pt} +\textcolor{blue}{\huge Advanced features of Functions} +\end{center} +\vspace{18pt} +\begin{center} +\vspace{10pt} +\includegraphics[scale=0.95]{../images/fossee-logo.png}\\ +\vspace{5pt} +\scriptsize Developed by FOSSEE Team, IIT-Bombay. \\ +\scriptsize Funded by National Mission on Education through ICT\\ +\scriptsize MHRD,Govt. of India\\ +\includegraphics[scale=0.30]{../images/iitb-logo.png}\\ +\end{center} +\end{frame} \begin{frame} -\frametitle{Outline} -\label{sec-1} +\frametitle{Objectives} +\label{sec-2} + + At the end of this tutorial, you will be able to, + \begin{itemize} -\item Assigning default values to arguments -\item Calling functions using Keyword arguments -\item functions in standard library +\item Assign default values to arguments, when defining functions. +\item Define and call functions with keyword arguments. +\item Learn some of the built-in functions available in Python standard + library and the scientific computing libraries. \end{itemize} \end{frame} \begin{frame} -\frametitle{Question 1} -\label{sec-2} +\frametitle{Pre-requisite} +\label{sec-3} + +Spoken tutorial on - + +\begin{itemize} +\item Getting started with functions +\end{itemize} +\end{frame} +\begin{frame}[fragile] +\frametitle{Functions} +\label{sec-4} - Redefine the function \texttt{welcome}, by interchanging it's - arguments. Place the \texttt{name} argument with it's default value of - ``World'' before the \texttt{greet} argument. +\lstset{language=Python} +\begin{lstlisting} +s.strip() #strips on spaces. +s.strip('@') #strips the string of '@' symbols. + +plot(x, y) #plots x v/s y using default line style. +plot(x, y, 'o') #plots x v/s y with circle markers. + +linspace(0,2*pi,100) #returns 100 pts. between 0 & 2pi +linspace(0,2*pi) #returns 50 pts. between 0 & 2pi +\end{lstlisting} +\end{frame} +\begin{frame} +\frametitle{Exercise 1} +\label{sec-5} + + +\begin{itemize} +\item Redefine the function \verb~welcome~, by interchanging it's + arguments. +\vspace{3pt} + Place the \verb~name~ argument with it's default value of + ``World'' before the \verb~greet~ argument. +\end{itemize} \end{frame} \begin{frame}[fragile] \frametitle{Solution 1} -\label{sec-3} +\label{sec-6} -\begin{verbatim} +\lstset{language=Python} +\begin{lstlisting} def welcome(name="World", greet): print greet, name -\end{verbatim} - We get an error that reads \texttt{SyntaxError: non-default argument follows default argument}. When defining a function all the +\end{lstlisting} +\vspace{5pt} + We get an error that reads, \\ \verb~SyntaxError: non-default argument follows default~ +\verb~argument~. +\vspace{5pt} +\\ When defining a function all the argument with default values should come at the end. \end{frame} \begin{frame} -\frametitle{Question 2} -\label{sec-4} +\frametitle{Exercise 2} +\label{sec-7} + - See the definition of linspace using \texttt{?} and observe how all the +\begin{itemize} +\item See the definition of linspace using \verb~?~ and make a note of all the arguments with default values are towards the end. +\end{itemize} +\end{frame} +\begin{frame} +\frametitle{Exercise 3} +\label{sec-8} + + +\begin{itemize} +\item Redefine the function \verb~welcome~ with a default value of + ``Hello'' to the \verb~greet~ argument.\\ + Then, call the function without any arguments. +\end{itemize} \end{frame} \begin{frame}[fragile] -\frametitle{Solution 2} -\label{sec-5} +\frametitle{Keyword arguments examples} +\label{sec-9} + +\lstset{language=Python} +\begin{lstlisting} +legend(['sin(2y)'], loc = 'center') + +plot(y, sin(y), 'g', linewidth = 2) + +annotate('local max', xy = (1.5, 1)) -\begin{verbatim} -linspace? -\end{verbatim} +pie(science.values(), labels = science.keys()) +\end{lstlisting} \end{frame} -\begin{frame} -\frametitle{Question 3} -\label{sec-6} +\begin{frame}[fragile] +\frametitle{Built-in functions} +\label{sec-10} - Redefine the function \texttt{welcome} with a default value of - ``Hello'' to the \texttt{greet} argument. Then, call the function without any - arguments. +\lstset{language=Python} +\begin{lstlisting} +Math functions - abs, sin, .... + +Plot functions - plot, bar, pie ... + +Boolean functions - and, or, not ... +\end{lstlisting} \end{frame} \begin{frame}[fragile] -\frametitle{Solution 3} -\label{sec-7} +\frametitle{Classes of functions} +\label{sec-11} -\begin{verbatim} -def welcome(greet="Hello", name="World"): - print greet, name +\lstset{language=Python} +\begin{lstlisting} +- pylab + - plot, bar, contour, boxplot, errorbar, log, polar, + quiver, semilog -welcome() -\end{verbatim} +- scipy (modules) + - fftpack, stats, linalg, ndimage, signal, optimize, + integrate +\end{lstlisting} \end{frame} \begin{frame} \frametitle{Summary} -\label{sec-8} +\label{sec-12} + + In this tutorial, we have learnt to, + + +\begin{itemize} +\item Define functions with default arguments. +\item Call functions using keyword arguments. +\item Use the range of functions available in the Python standard library + and the Scientific Computing related packages. +\end{itemize} +\end{frame} +\begin{frame}[fragile] +\frametitle{Evaluation} +\label{sec-13} + - You should now be able to -- +\begin{enumerate} +\item All arguments of a function cannot have default values. + True or False? +\vspace{3pt} +\item The following is a valid function definition. True or False? +\lstset{language=Python} +\begin{lstlisting} +def seperator(count=40, char, show=False): + if show: + print char * count + return char * count +\end{lstlisting} +\vspace{3pt} +\item When calling a function, \begin{itemize} -\item define functions with default arguments -\item call functions using keyword arguments +\item the arguments should always be in the order in which they are defined. +\item only keyword arguments can be in any order, but should be called + at the beginning. +\item only keyword arguments can be in any order, but should be called at the end. \end{itemize} +\end{enumerate} +\end{frame} +\begin{frame} +\frametitle{Solutions} +\label{sec-14} + + +\begin{enumerate} +\item False +\vspace{12pt} +\item False +\vspace{12pt} +\item Only keyword arguments can be in any order, + but should be called at the end. +\end{enumerate} \end{frame} \begin{frame} -\frametitle{Thank you!} -\label{sec-9} \begin{block}{} \begin{center} - This spoken tutorial has been produced by the - \textcolor{blue}{FOSSEE} team, which is funded by the + \textcolor{blue}{\Large THANK YOU!} \end{center} + \end{block} +\begin{block}{} \begin{center} - \textcolor{blue}{National Mission on Education through \\ - Information \& Communication Technology \\ - MHRD, Govt. of India}. + For more Information, visit our website\\ + \url{http://fossee.in/} \end{center} \end{block} \end{frame} -\end{document} +\end{document}
\ No newline at end of file |