Finished sets
authorNishanth <nishanth@fossee.in>
Tue, 12 Oct 2010 11:19:09 +0530
changeset 333 91b427241f8f
parent 332 b702c10e5919
child 334 4b1e81da1c80
Finished sets
sets/quickref.tex
sets/script.rst
--- a/sets/quickref.tex	Tue Oct 12 11:09:52 2010 +0530
+++ b/sets/quickref.tex	Tue Oct 12 11:19:09 2010 +0530
@@ -1,11 +1,23 @@
-Creating a tuple:\\
-{\ex \lstinline|    t = (1, "hello", 2.5)|}
+Creating a set:\\
+{\ex \lstinline|   p10 = set([2, 3, 5, 7]) |t}
 
-Accessing elements of tuples:\\
-{\ex \lstinline|    t[index] Ex: t[2]|}
+Creating set from a tuple or list:\\
+{\ex \lstinline|   s = set(var_name)|}
+
+Operations on sets. Ex: UNION:\\
+{\ex \lstinline|   s1 \| s2 |}
+
+Other operations available:\\
 
-Accessing slices of tuples:\\
-{\ex \lstinline|    t[start:stop:step]|}
+\begin{lstlising}
+\item "\&" -- Intersection
+\item "-" -- Difference
+\item "\^" -- Symmetric Difference
+\item "<" -- Subset
+\end{lstlisting}
 
-Swapping values:\\
-{\ex \lstinline|    a, b = b, a|}
+Checking for containership:\\
+{\ex \lstinline|    x in p10|}
+
+Finding the no.of elements:\\
+{\ex \lstinline|    len(p10)|}
--- a/sets/script.rst	Tue Oct 12 11:09:52 2010 +0530
+++ b/sets/script.rst	Tue Oct 12 11:19:09 2010 +0530
@@ -1,11 +1,13 @@
 .. Objectives
 .. ----------
 
-.. A - Students and teachers from Science and engineering backgrounds
-   B - Will learn what are tuples and why they are needed
-       Will learn the various methods of accessing elements in tuples
-   C - 
-   D - 
+.. By 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
+
 
 .. Prerequisites
 .. -------------