



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Today ...
Reading
HW
Reminders
Consider this code snippet z = 10 def f(x, y, z): tmp = x + y // z return tmp What is the result of the following statements?
(a) tmp = 40 z = 30 is printed (b) tmp = 40 z = 10 is printed (c) Syntax error (d) None of the above
The index (aka subscript) operator
listvar[index]
the list = [10, 20, 30]
first elem = the list[0] print(first elem)
10
Subscripts can be used to change list values
the list[0] = 15
print(the list)
[15, 20, 30]
The type of a list ...
the_list = [2, 4, 6] type(the_list) <class ’list’>
the_list = [’s’, ’p’, ’a’, ’m’] type(the_list) <class ’list’>