I have wrote this code but it shows me only the timing not the values, can any bady tell me where is the problem?

import time
import random 


def procedure():
    time.sleep(0.60)

 # measure process time
t0 = time.clock()
procedure()
print time.clock() - t0, "seconds process time"

#BUCKET SORT (up to 30)

def bucket_sort(lst):
    bucket, bucket1, bucket2 = [], [], [] #The three empty buckets
    #Populating the buckets with the list elements
    for i in range(len(lst)):
        if lst[i] in range(11):
            bucket.append(lst[i])
        elif lst[i] in range(21):
            bucket1.append(lst[i])
        elif lst[i] in range(31):
            bucket2.append(lst[i])

#Prints the buckets and their contents

    print "Bucket:",bucket
    print "Bucket1:",bucket1
    print "Bucket2:",bucket2

 #The actual sorting

    bucket.sort()
    bucket1.sort()
    bucket2.sort()
    final_lst = bucket + bucket1 + bucket2
    print "Sorted list:",final_lst

You need to create a random list for the bucket_sort argument lst ...

import time
import random

#BUCKET SORT (up to 30)

def bucket_sort(lst):
    bucket, bucket1, bucket2 = [], [], [] #The three empty buckets
    #Populating the buckets with the list elements
    for i in range(len(lst)):
        if lst[i] in range(11):
            bucket.append(lst[i])
        elif lst[i] in range(21):
            bucket1.append(lst[i])
        elif lst[i] in range(31):
            bucket2.append(lst[i])

#Prints the buckets and their contents

    print "Bucket:",bucket
    print "Bucket1:",bucket1
    print "Bucket2:",bucket2


#The actual sorting

    bucket.sort()
    bucket1.sort()
    bucket2.sort()
    final_lst = bucket + bucket1 + bucket2
    print "Sorted list:", final_lst

# create random list with 30 integers from 0 to 50
lst = random.sample(range(50), 30)
print lst  # test

# call bucket_sort and time it
t0 = time.clock()
bucket_sort(lst)
print time.clock() - t0, "seconds process time"

The print statements inside your bucket_sort will be the slowest part.

Thank You, that's it what I was lloking for. Thanks again :) Vegaseat

Dear Vegasite how to generate time executation for each random number that is sort?

import time
import random
#BUCKET SORT (up to 30)
def bucket_sort(lst):
    bucket, bucket1, bucket2 = [], [], [] #The three empty buckets
    #Populating the buckets with the list elements
    for i in range(len(lst)):
        if lst[i] in range(11):
            bucket.append(lst[i])
        elif lst[i] in range(21):
            bucket1.append(lst[i])
        elif lst[i] in range(31):
            bucket2.append(lst[i])
#Prints the buckets and their contents
    print "Bucket:",bucket
    print "Bucket1:",bucket1
    print "Bucket2:",bucket2
#The actual sorting
    bucket.sort()
    bucket1.sort()
    bucket2.sort()
    final_lst = bucket + bucket1 + bucket2
    print "Sorted list:", final_lst
# create random list with 30 integers from 0 to 50
lst = random.sample(range(50), 30)
print lst  # test
# call bucket_sort and time it
t0 = time.clock()
bucket_sort(lst)
print time.clock() - t0, "seconds process time"
This question has already been answered. Start a new discussion instead.