diff options
author | Jovina | 2011-07-07 12:04:28 +0530 |
---|---|---|
committer | Jovina | 2011-07-07 12:04:28 +0530 |
commit | e4f4729e02d3a550f74c52210ea619f8dadb4283 (patch) | |
tree | 823c2b5509cfbba45c959e171061ee11e72e0d48 /sets/slides.org | |
parent | ab0b9d6fa8b1971433d1daf092afeb83aae2256c (diff) | |
download | st-scripts-e4f4729e02d3a550f74c52210ea619f8dadb4283.tar.gz st-scripts-e4f4729e02d3a550f74c52210ea619f8dadb4283.tar.bz2 st-scripts-e4f4729e02d3a550f74c52210ea619f8dadb4283.zip |
Major changes to script & slides of 'Sets'.
Diffstat (limited to 'sets/slides.org')
-rw-r--r-- | sets/slides.org | 97 |
1 files changed, 65 insertions, 32 deletions
diff --git a/sets/slides.org b/sets/slides.org index 9f056d9..2869eca 100644 --- a/sets/slides.org +++ b/sets/slides.org @@ -18,7 +18,7 @@ #+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen}, #+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries} -#+TITLE: Sets +#+TITLE: #+AUTHOR: FOSSEE #+EMAIL: #+DATE: @@ -29,43 +29,76 @@ #+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 - - Defining Sets - - Operations on sets - -* Question 1 - Given a list of marks, ~marks = [20, 23, 22, 23, 20, 21, 23]~ list - all the duplicates -* Solution 1 - #+begin_src python - marks = [20, 23, 22, 23, 20, 21, 23] - marks_set = set(marks) - for mark in marks_set: - marks.remove(mark) - - # we are now left with only duplicates - # in the list marks - duplicates = set(marks) - - #+end_src +* +#+begin_latex +\begin{center} +\vspace{12pt} +\textcolor{blue}{\huge Sets} +\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, + + - Create sets from lists. + - Perform union, intersection and symmetric difference operations. + - Check if a set is a subset of other. + - Understand various similarities with lists like length and containership. + +* Pre-requisite +Spoken tutorial on - +- Getting started with Lists +* Exercise 1 + - Given a list of marks, + ~marks = [20, 23, 22, 23, 20, 21, 23]~ + List all the duplicates * Summary - You should now be able to -- - + make sets from lists - + input sets directly - + perform operations like union, intersection, symmetric difference - + check if a subset of another - + check containership, length and other properties similar to lists -* Thank you! + In this tutorial, we have learnt to, + + - Make sets from lists. + - Perform union, intersection and symmetric difference operations. + by using the operators `|`, `&` and ` \^ ` respectively. + - Check if a set is a subset of other using the `<` and `<=` operators. + - Understand various similarities with lists like length and containership. +* Evaluation +1. If ~a = [1, 1, 2, 3, 3, 5, 5, 8]~. What is set(a)? + + - set([1, 1, 2, 3, 3, 5, 5, 8]) + - set([1, 2, 3, 5, 8]) + - set([1, 2, 3, 3, 5, 5]) + - Error + +2. Given, ~odd = set([1, 3, 5, 7, 9])~ and ~squares = set([1, 4, 9, 16])~. + How do you find the symmetric difference of these two sets? + + +3. ``a'' is a set. how do you check if a variable ``b'' exists in ``a''? +* Solutions +1. set([1, 2, 3, 5, 8]) + +2. odd ^ squares + +3. b in a +* #+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 |