Member Avatar for leegeorg07

hey again i started to look at the time module a lot and i made this program:

import time

time.clock
a = 0
print('hello')
while a < 10000:
    print(a)
    a+=1

a = time.clock()

print(a)

but i dont understand what a means so can you help me please

It would help me if you told us what it is you're trying to do. Right now your program creates a counter, a, and then prints about 10,000 numbers. But you're not really doing anything with the time module. If you could tell us what you want, maybe I could whip up an example.

Member Avatar for leegeorg07

i am trying to use the time.clock() function to clock the amount of time needed to perform the counter. all i really want is how to understand the number that comes out

Here is an example. Make sure you check out the link I put in the comments.

# Here is an excellent set of examples you should look at
# http://pleac.sourceforge.net/pleac_python/datesandtimes.html

import time
import datetime

first = datetime.datetime.now()

while a < 10000:
    a += 1

second = datetime.datetime.now()

print 'The whole thing took ' + time.mktime(first.timetuple()) - time.mktime(second.timetuple()) + ' seconds.'
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.