lec-10-23

lec-10-23 - New Assignment Due Tuesday. Should be quick...

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

View Full Document Right Arrow Icon
1 ECS10 10/24 New Assignment ± Due Tuesday. ± Should be quick once you understand the concepts. ± Lists for loops and string methods (today’s Lists, for loops, and string methods (today s topic). Loop on integers count = 0 while count < 5: print count count = count+1 Count is the index variable. Loop over integers for count in [0,1,2,3,4]: print count Shorter Shorter with a with a for loop loop. But we might need . But we might need to make a very long list. Loop over integers for count in range(5): print count Prettier with the Prettier with the range range function. function. Range function for count in range(5): print count ± range(5 ) is a built-in function ± Produces the list [0,1,2,3,4] ± range(1,6) produces the list [1,2,3,4,5]
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 Range function string = ‘’ for count in range(5): string = string + ‘ha’ ± Standard way to do something a fixed number of times. range()
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/14/2010 for the course ECS 10 taught by Professor Amenta during the Spring '07 term at UC Davis.

Page1 / 3

lec-10-23 - New Assignment Due Tuesday. Should be quick...

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

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