I am trying to write a program that generates a list and a random number on 3 seperate occations, then checks the list to see if the number is in the list, all the while, timing the procedure( Python code)
1st list is 1-100, 2nd list is 1-1000, third list is 1-10000, Print the results along with the time elapsed, thanks

import random

import time

def orderedSequentialSearch(alist, item):
    pos = 0
    found = False
    stop = False
    while pos < len(alist) and not found and not stop:
        if alist[pos] == item:
            found = True
        else:
            if alist[pos] > item:
                stop = True
            else:
                pos = pos+1

    return found

def main():
    start = time.clock()
    for count in range(1,100):
        
        print random.randint

        count = orderedSequentialSearch(alist)
        random.randint = orderedSequentialSearch(item)
        elapsed = (time.clock() - start)
        if found == False:
            print item, ("was not found in the list . Time : "),elapsed
        else:
            print item, ("was found in the the list. Time : "), elapsed
            
    start = time.clock()
    
    for count in range(1,1000):
        print random.randint

        count = orderedSequentialSearch(alist)
        random.randint = orderedSequentialSearch(item)
        elapsed = (time.clock() - start)
        if found == False:
            print item, ("was not found in the list . Time : "),elapsed
        else:
            print item, ("was found in the the list. Time : "), elapsed
            
    start = time.clock() 
    for count in range(1,10000):
        
        print random.randint
        elapsed = (time.clock() - start)
        count = orderedSequentialSearch(alist)
        random.randint = orderedSequentialSearch(item)
         
        if found == False:
            print item, ("was not found in the list . Time : "),elapsed
        else:
            print item, ("was found in the the list. Time : "),elapsed

main()

Please use code tags, even if it is quick.

What exactly is your question?

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.