108HL14 - List Methods Lecture 14, Week 5 February 9, 2011...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
List Methods Lecture 14, Week 5 February 9, 2011 CSC108H1S Velian Pandeliev 1 Wednesday, February 9, 2011
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Recap of Lecture 13 Wednesday, February 9, 2011
Background image of page 2
Lists 3 In Python, a list is an ordered collection of heterogeneous values. Lists are ordered because every element in a list has a speciFc place in the list. Lists are heterogeneous : they can contain different data types, including other lists. Lists can contain duplicate values. Wednesday, February 9, 2011
Background image of page 3

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

View Full DocumentRight Arrow Icon
List Syntax 4 In Python, a list is an ordered collection of heterogeneous values. It is created (initialized) as follows: listname = [ elmt1 , elmt2 , elmt3 ] Lists are indexed , just like strings, meaning that once created, each element of a list can be accessed using the syntax: listname [ index ] Lists can also be sliced using listname [a:b] . Wednesday, February 9, 2011
Background image of page 4
Iterating Over Lists I 5 Just like with strings, we can iterate over lists: we can perform an action for each element in a list. We do this using the
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/25/2011 for the course CSC 108 taught by Professor Gries during the Spring '08 term at University of Toronto- Toronto.

Page1 / 11

108HL14 - List Methods Lecture 14, Week 5 February 9, 2011...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online