Changes

Jump to: navigation, search

OPS435 Python Lab 4

154 bytes added, 09:50, 14 June 2017
PART 1 - Tuples
print(list2)
</source>.You should have been successful in changing the value of your list.<br><br>
:#Try Now, try changing a tuple value.by issuing the following:<source>
t2[1] = 10
</source>sourc:#Did it work? Once created the tuple values will not be able to change. <br><br>If you would like a tuple with different values than the tuple you currently have, then you must create a new one.<br><br>:#To create a new tuple, issue the following:<source>
t3 = t2[2:3]
</source>
:#You however can still use most of the basic operations with tuples as you might expect from tuplesdid with lists.<br><br>:#To demonstrate, issue the following:<source>
len(t1) # list the length of the tuple
t1 * 3 # repititionrepetition
t1 + t2 # concatenation, remember this is creating a new tuple, not modifying
</source>
:#Like Also, as with lists, you can also loop through the values of use loops with tuples.Issue the following to demonstrate:<source>
for item in t1:
print('item: ' + item)
13,420
edits

Navigation menu