Tony Noyeaux wrote: > As always, thanks all for the ongoing help and suggestions... the > learning continues. > > I've successfully made a number of programs, making use of various > random code. > > Using random.choice etc > #----------------------------------- > import random > letters = ('a', 'b', 'c', 'd') > a = random.choice(letters) > print 'your random letter is %s' %(a) > #------------------------------------ > or > #------------------------------------ > import random > letters = ('a', 'a', 'b', 'b', 'c', 'd') > a = random.choice(letters) > print 'your random letter is %s' %(a) > #----------------------------------- > > In the first random... , each abcd, has a equal chance of coming out. > In the 2nd random,... a b,.. have an extra chance vs c/d to come out, > making them more likely. > > What i would like to experiment now with is,... > > How can you control randomness... lets say for fish. > > CatfishBreedA > Can be say, 4inches, to 24inches long > Most fish caught are say 7-14inches long > Maybe 1 in 1000 catfish caught are say, 16-20 inches long > Maybe 1 in 10000 catfish caught are say, 20inches + > > How.. can you program that kind of randomness? > > Or another way to look at it. > > BasketballerA > Can score 4-45pts a game. > Most games, he scores 15-25 pts > Maybe 1 in 1000 games he scores 30 plus pts > Maybe 1 in 10000 he scores 45 pts. > > The actual %'s, lengths, and pts are irrelevent,.. they are just used > to as an example. > > > Any guidance would be appreciated. 10000 games would be distributed thus: 1 = 45 pts 10 = 30+ pts 99989 = 15-25 pts so generate a random integer between 1 and 10000. if it is <= 1 then 45 else if it is <= 11 then 30+ else 15-25
Enough to get you going? -- Bob Gailer 510-978-4454 Oakland, CA 919-636-4239 Chapel Hill, NC _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor