[ILUG] Generate random numbers and survey results analysis

Nick Murtagh nickm at go2.ie
Wed Jul 25 17:31:42 IST 2007


Patrick O'Connor wrote:
> I was hoping to use the lnux rand() or srand() functions to randomly pick 8
> winners from a number range of 1 to 145 but my efforts have been fruitless
> so far.
> Does anyone have a script that I can use to accomplish this?

$ python
>>> import random
>>> l = range(1, 146)
>>> random.shuffle(l)
>>> l[:8]
[136, 60, 123, 132, 40, 79, 33, 53]


-- 
Nick Murtagh <nickm at go2.ie>
go2web Ltd., Harbour House, Harbour Road, Howth, Dublin 13
http://www.go2.ie/ - Phone +353-(0)1-839-5432 - Fax +353-(0)1-839-5439
Registered in Ireland: No. 327376
Registered address: 53 Thormanby Lawns, Howth, Dublin 13



More information about the ILUG mailing list