[Tutor] clock.py
Nick Lunt
nick at javacat.f2s.com
Mon May 23 18:36:05 CEST 2005
Feziwe Mpondo wrote:
>clock.py,problem is to get the last two digits to be random.her's what i
>tried
>from time import time,ctime
>prev_time = ""
>while(1):
> the_time = ctime()
> if (prev_time != the_time):
> print "The time is :",ctime(time())
>prev_time = the_time
>guess = 0
>number = 1-60
>while guess != number:
> guess = input ("Guess the last two digits:")
> if guess > number:
> print "Too high"
> elif guess < number:
> print "Too low"
>print "Just right"
>_______________________________________________
>Tutor maillist - Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>
Hi Feziwe,
you might want to look at the random module to generate 'guess'
ramdon.randrange() more specifically.
Nick .
More information about the Tutor
mailing list