----- Original Message -----
Message: 1
Date: Wed, 16 Sep 2009 23:19:39 -0400
From: Kent Johnson <ken...@tds.net>
To: Laurii <the_only_kat...@verizon.net>
Cc: tutor@python.org
Subject: Re: [Tutor] Using the time module to extract a semi-random
number
Message-ID:
<1c2a2c590909162019l364b516cifcd2e0befe2ad...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
On Wed, Sep 16, 2009 at 6:43 PM, Laurii <the_only_kat...@verizon.net>
wrote:
The exercise to modify a number guessing program from a fixed number
"number
= 78" to using the time module and use the seconds at the time the
program
is used to be the number. (i.e. if the clock on your computer says
7:35:25
then it would take the 25 and place it in "number".
time.localtime().tm_sec will give you the number of seconds as an
integer without any conversions.
Kent
------------------------------
Message: 2
Date: Thu, 17 Sep 2009 10:50:11 +0200
From: Patrick Sabin <patrick.just4...@gmail.com>
To: Tutor@python.org
Subject: Re: [Tutor] Using the time module to extract a semi-random
number
Message-ID: <4ab1f843.1060...@gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Laurii wrote:
Hello all,
I am currently reading through the Tutorial for Non-Programers by Josh
Cogliati. I have had great success until now.
The exercise to modify a number guessing program from a fixed number
"number = 78" to using the time module and use the seconds at the time
the program is used to be the number. (i.e. if the clock on your
computer says 7:35:25 then it would take the 25 and place it in "number".
You can either use:
import time
number = int(time.strftime("%S"))
or use real pseudo-random numbers:
import random
number = random.randint(0,59)
The latter looks clearer to me.
Thank you everyone for your help. Even just the examples you have posted
have been easier to understand than the python documentation.
One last question on the TIME module: Is there one version of these examples
that is not portable to other systems? I read something about some
functions not working on other systems and I would like to ensure that the
programs that I write are completely portable.
Thanks again,
Katt
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor