[Tutor] generate random number list and search for number
alan.gauld at btinternet.com
Tue Aug 11 10:28:47 CEST 2015
On 11/08/15 04:18, Quiles, Stephanie wrote:
> Totally lost here.
Most of the instructions are clearly listed. Just follow through and do
what it suggests one step at a time.
> • First, we’ll need to import time to use the clock routine,
So import time
> and we’ll need to use the randrange routine from random.
and import random.
Well done I see you did that.
> • Next, we’ll want our main( ) routine to call our createRandnums( ) routine
> and have this routine return our list of random numbers.
It says 'our' routine so you need to create it.
It goes on to tell you how:
> • The createRandnums routine will accept two parameters
> (how many numbers do you want, and what is the upper limit on
> the randrange routine), and this will simply run a loop to
> create the numbers and append them to a list. Once the list
> is complete, we can then use the sort routine on the list to
> arrange the numbers in order. The function will now return
> the sorted list to main( ).
So that's your next task.
write the function definition and create a main() that simply
calls createRandnums(quantity, limit)
To check it works print the result.
Forget about the rest of the assignment until you get that
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:
More information about the Tutor