Using ctime to use the last two digits of time?
peter at engcorp.com
Mon Jun 16 18:04:41 CEST 2003
> In reference to the Exercise on the bottom of this page;
> "use the last two digits of time at that moment to be the 'random'
> number. "
> Now, I'm assuming that you need to use ctime to do this - but I have
> absolutely no idea how to modify the ctime statement in order for it
> to produce the last two digits (the seconds, respectively).
Why would you assume that?
My guess would be that it expects you to take the result of time.time()
and use the last two digits from *that*, but I could be wrong. In any
case, the problem seems under-specified, so you should either ask for
more detail, or assume the simplest possible intention and go with that.
Also, you probably shouldn't plan to "modify the ctime" statement or
any other, but to work on the value returned by the function in question
and manipulate it in such a way that you retrieve the last two digits
from it. Don't change the guts of anything, just add new code around it.
Before posting again, you might try a few experiments and, if it
doesn't work, post examples of what you've tried. That way we at
least know we're not just handing you the solution on a silver platter.
(I realize you didn't ask for that.)
More information about the Python-list