Open main menu

CDOT Wiki β

Changes

OPS435 Python Lab 4

29 bytes added, 16:25, 14 June 2017
PART 2 - Sets
s3 = {4, 5, 6, 7, 8}
</source>Note: '''Sets are defined by using braces { }''' as opposed to tuples that use parenthesis ( ), or lists that use square brackets [ ]'''<br><br>
:#First, Try to issue the following to access a set through the index.<source>
s1[0]
</source>This should have created an '''error''', this is not how to access data inside a set because they are '''un-ordered'''. Instead, you should use the method (used in the previous section) to check to see if a value is contained within the set.<br><br>
:#To demonstrate, issue the following:<source>
'Ix' in s1
13,420
edits