Changes

Jump to: navigation, search

OPS435 Python Lab 4

7 bytes added, 16:45, 14 June 2017
PART 2 - Sets
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 display '''values that are common to both sets'''. This is known in mathematical terms as an '''intersection''' between the lists.<br><br>
:#To demonstrate intersection between sets s2 and s3, issue the following:<source>
s2
s3
s2 & s3 # returns a set containing all values that s2 and s3 share
s2.intersection(s3) # same as s2 & s3
13,420
edits

Navigation menu