diff options
author | Nishanth Amuluru | 2010-10-12 11:19:09 +0530 |
---|---|---|
committer | Nishanth Amuluru | 2010-10-12 11:19:09 +0530 |
commit | 7f8225acf6269500fa02664c4d28d8343fb7f23c (patch) | |
tree | b1c1e7e6ea5dc492e946dd4e85250afaa3bb0da9 /sets | |
parent | d2fd725a6c7ad2f5676c0684ba73a6c3e30596dd (diff) | |
download | st-scripts-7f8225acf6269500fa02664c4d28d8343fb7f23c.tar.gz st-scripts-7f8225acf6269500fa02664c4d28d8343fb7f23c.tar.bz2 st-scripts-7f8225acf6269500fa02664c4d28d8343fb7f23c.zip |
Finished sets
Diffstat (limited to 'sets')
-rw-r--r-- | sets/quickref.tex | 28 | ||||
-rw-r--r-- | sets/script.rst | 12 |
2 files changed, 27 insertions, 13 deletions
diff --git a/sets/quickref.tex b/sets/quickref.tex index a0212b3..4e34e59 100644 --- a/sets/quickref.tex +++ b/sets/quickref.tex @@ -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)|} -Accessing slices of tuples:\\ -{\ex \lstinline| t[start:stop:step]|} +Operations on sets. Ex: UNION:\\ +{\ex \lstinline| s1 \| s2 |} -Swapping values:\\ -{\ex \lstinline| a, b = b, a|} +Other operations available:\\ + +\begin{lstlising} +\item "\&" -- Intersection +\item "-" -- Difference +\item "\^" -- Symmetric Difference +\item "<" -- Subset +\end{lstlisting} + +Checking for containership:\\ +{\ex \lstinline| x in p10|} + +Finding the no.of elements:\\ +{\ex \lstinline| len(p10)|} diff --git a/sets/script.rst b/sets/script.rst index ffc2084..8f9c699 100644 --- a/sets/script.rst +++ b/sets/script.rst @@ -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 .. ------------- |