108HL15 - Mutability and List Examples Lecture 15 Week 5...

Info icon This preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Mutability and List Examples Lecture 15, Week 5 February 11, 2011 CSC108H1S Velian Pandeliev 1 Friday, February 11, 2011
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Announcements 2 Quiz 2 average was 52% !" !$ % $ " & ' (% )*+, ( )*+, $ )*+, - )*+, " Friday, February 11, 2011
Image of page 2
About Quiz 2 3 Quiz 2 was the first time you had to write code from scratch on paper in a time-pressured situation. Wednesday's midterm is going to be like that, except longer. Today's lecture is the last one for which you're responsible on Wednesday. Monday's class will be a review class. Please post to the Discussion Board in topic "Velian's Midterm Review Questions" with topics you would like us to go over. Friday, February 11, 2011
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
4 Recap of Lecture 14 Friday, February 11, 2011
Image of page 4
List Methods 5 Lists, like strings, have a wide variety of useful methods. Using a list called lst : lst.index(item) - returns the index of the first time item appears in lst lst.count(item) - returns the number of times item appears in lst lst.insert(index, item) - inserts item before position index in lst lst.remove(item) - removes the first occurrence of item from lst Friday, February 11, 2011
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
List Methods 6 lst.append(item) - adds item to the end of lst lst.pop(index) - removes and returns the item at index . If index is not supplied, removes and returns the last item in lst lst.extend(anotherlist) - adds all the items in anotherlist to the end of lst lst.reverse() - reverses the order of items in lst lst.sort() - sorts the items in lst in alphanumeric order Friday, February 11, 2011
Image of page 6
7 List Examples Friday, February 11, 2011
Image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern