Changes

Jump to: navigation, search

OPS435 Python Lab 4

155 bytes added, 09:41, 14 June 2017
PART 1 - Tuples
:#Launch your ipython3 shell:<source>
ipython3
</source>Let's create two tuples, so we can learn how to use them and learn how they differ from lists.<br><br>Note: '''tuples are defined by using parenthesis ( )''' as opposed to '''lists are defined by using square brackets [ ]'''<br><br>
:#Issue the following:<source>
t1 = ('Prime', 'Ix', 'Secundus', 'Caladan')
t1[0]
t2[2:4]
</source>:#You can also check to see whether a value exists inside a tuple or not.:#Issue To demonstrate, issue the following:<source>
'Ix' in t1
'Geidi' in t1
</source>Let's now see how a tuple differs from a list. We will now create a list and note the difference between them.<br><br>
:#Issue the following to create a list:<source>
13,420
edits

Navigation menu