Re: [Tutor] no loops

2006-07-11 Thread Alan Gauld
> def increment(time, seconds): > time.seconds = time.seconds + seconds > > while time.seconds >= 60: >time.seconds = time.seconds - 60 >time.minutes = time.minutes + 1 Tale a look at what this loop is doing. Think about its purpose. If you werre doing this with paper and pencil would

Re: [Tutor] no loops

2006-07-11 Thread Bob Gailer
Christopher Spears wrote: > I am working on another problem from "How To Think > Like A Computer Scientist". Here is a function: > > def increment(time, seconds): > time.seconds = time.seconds + seconds > > while time.seconds >= 60: > time.seconds = time.seconds - 60 > time.minutes = t

Re: [Tutor] no loops

2006-07-11 Thread Marc Poulin
--- John Fouhy <[EMAIL PROTECTED]> wrote: > On 12/07/06, Christopher Spears > <[EMAIL PROTECTED]> wrote: > > Now the exercise is: > > As an exercise, rewrite this function so that it > > doesn't contain any loops. > > > > I have been staring at this function and drawing a > > blank. Something te

Re: [Tutor] no loops

2006-07-11 Thread John Fouhy
On 12/07/06, Christopher Spears <[EMAIL PROTECTED]> wrote: > Now the exercise is: > As an exercise, rewrite this function so that it > doesn't contain any loops. > > I have been staring at this function and drawing a > blank. Something tells me that I need to use > iteration, but I am not sure how

Re: [Tutor] no loops

2006-07-11 Thread Gregor Lingl
Christopher Spears schrieb: IF you know that it's 2 seconds after midnight, how many hours, minutes, seconds after midnight ist this. If you should compute this by hand, how would you proceed? Best wishes, Gregor > I am working on another problem from "How To Think > Like A Computer Scienti

[Tutor] no loops

2006-07-11 Thread Christopher Spears
I am working on another problem from "How To Think Like A Computer Scientist". Here is a function: def increment(time, seconds): time.seconds = time.seconds + seconds while time.seconds >= 60: time.seconds = time.seconds - 60 time.minutes = time.minutes + 1 while time.minutes >= 6