lec-10-21

lec-10-21 - Announcements Raw midterm scores are on...

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

View Full Document Right Arrow Icon
1 ECS10 10/21 Announcements ± Raw midterm scores are on SmartSite. ± Programs handed back in section. ± If you want to see your Scantron, ask me in my Lab Hours (Mon AM 911)orOf f iceHours Lab Hours (Mon AM 9-11) or Office Hours (Wds 2-3:30). ± If you did poorly, especially on the program, take it as a wake-up call. You need to master Chapters 1-3 in the book. Loop over a string strIn = “5,236,320” i = 0 strOut = “” while i < len(strIn): char = strIn[i] if char != “,”: strOut = strOut+char i = i+1 Eliminates the commas. for loop over a string strIn = “5,342,750” strOut = “” for char in strIn: if char != “,”: strOut = strOut+char ± Exactly the same effect as version using while. ± Prettier, shorter. ± char takes on values “5”, then “,”, then “3”…. . for vs while ± Anything you can do with a for loop, you could also do with a while. ± for loops can only be used when you know how many times they will run before you start (length of list…) ± while loops are much more versatile, since you don’t need to know how many times it will loop.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
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-21 - Announcements Raw midterm scores are on...

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

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