> 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
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
--- 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
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
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
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