Programming Languages Transcript of Lecture of 13th October at 9:15 (* Demonstrates the list functions again from previous lecture *) >>> a = [0,1,2,3] >>> a[0] 0 >>> a[1] 1 >>> a{1:1] [] >>> a[0]=4 >>> a [4,1,2,3] (* How to reverse a list *) >>> a.reverse() >>> a [3,2,1,4] (* Adding 5 to the end of the list *) >>> a.append(5) >>> a [3,2,1,4,5] (* Remove and return the last item in the list *) >>> a.pop() 5 (* Create a new pointer to the same list *) >>> b = a >>> b.pop() 4 >>> b [3,2,1] >>> a [3,2,1] (* Create a pointer to a new copy of the list a *) >>> b = list(a) >>> b [3,2,1] >>> a [3,2,1] >>> b.pop() 1 >>> b [3,2] >>> a [3,2,1] (* How do a and b compare if they are both pointers to the same list? *) >>> a = [1,2,3] >>> b = a >>> b is a True >>> b == a True (* How do a and b compare if b points to a copy of a? *) >>> b = list(a) >>> b is a False >>> b==a True (* BONUS: Trying both comparison methods at the same time on a list and its copy *) >>> (b is a, b == a) (False, True)