[Tutor] I am puzzled - help needed
alan.gauld at freenet.co.uk
Thu Mar 31 18:41:23 CEST 2005
> exercise. I need to rewrite the high_low.py program (see below) to
> last two digits of time at that moment to be the "random number".
> using the import time module.
> I just can't work out how to do that, I have been looking at it for
> 2,5 hours but can't break it. Has anyone done it in order for me to
There are several ways, one is to convert the time number into a
then extract the last two digits and convert back to a number.
n = time.time()
s = str(n)
ran = s[-2:] # last two characters of the string
ran = int(ran) # convert back to a number
Another option is to divide by 100 and take the remainder...
More information about the Tutor