Open main menu

CDOT Wiki β

Changes

OPS435 Python Lab 4

289 bytes added, 16:39, 14 June 2017
PART 2 - Sets
'Ix' in s1
'Geidi' in s1
</source>:#<br>Sets can be combined together, but it is important to note that any duplicates that the 2 '''duplicate values (shared among sets share, ) will be deleted'''. Take a close look at which <br><br>:#Issue the following, and note the items (and values) that are shared between common to the following sets.:<source>
s2
s3
</source>
:#Now, issue the following to return a set contains all UNIQUE values from both sets:<source>
s2 | s3 # returns a set containing all values from both sets
s2.union(s3) # same as s2 | s3
</source>Notice that both methods above provides the same result, but the first method requires less keystrokes.<br><br>
:#Instead of combining sets, we can find out what values are in both sets. This is a intersection between the lists.<source>
s2
13,420
edits