equal
deleted
inserted
replaced
1 Creating a tuple:\\ |
1 Creating a set:\\ |
2 {\ex \lstinline| t = (1, "hello", 2.5)|} |
2 {\ex \lstinline| p10 = set([2, 3, 5, 7]) |t} |
3 |
3 |
4 Accessing elements of tuples:\\ |
4 Creating set from a tuple or list:\\ |
5 {\ex \lstinline| t[index] Ex: t[2]|} |
5 {\ex \lstinline| s = set(var_name)|} |
6 |
6 |
7 Accessing slices of tuples:\\ |
7 Operations on sets. Ex: UNION:\\ |
8 {\ex \lstinline| t[start:stop:step]|} |
8 {\ex \lstinline| s1 \| s2 |} |
9 |
9 |
10 Swapping values:\\ |
10 Other operations available:\\ |
11 {\ex \lstinline| a, b = b, a|} |
11 |
|
12 \begin{lstlising} |
|
13 \item "\&" -- Intersection |
|
14 \item "-" -- Difference |
|
15 \item "\^" -- Symmetric Difference |
|
16 \item "<" -- Subset |
|
17 \end{lstlisting} |
|
18 |
|
19 Checking for containership:\\ |
|
20 {\ex \lstinline| x in p10|} |
|
21 |
|
22 Finding the no.of elements:\\ |
|
23 {\ex \lstinline| len(p10)|} |