February 22nd, 2013, 08:15 PM

February 22nd, 2013, 08:42 PM

Combine a clever application of these codes:
Code:
import random
list_of_20_random_numbers = [random.random() for i in range(20)]
for i in range(8):
print('this event: {}'.format(i))
[code]
Code tags[/code] are essential for python code and Makefiles!
February 25th, 2013, 02:30 AM

Ok I can create five hundred random numbers but I cannot generate them a thousand times, I try it but it just loops the same thing thousand times. Would we have to use nested loops?
February 25th, 2013, 07:00 AM

Are you trying to get a matrix of random numbers?
(2 dimensional, like a populated spreadsheet page)
[code]
Code tags[/code] are essential for python code and Makefiles!
February 25th, 2013, 02:28 PM

Originally Posted by b49P23TIvg
Are you trying to get a matrix of random numbers?
(2 dimensional, like a populated spreadsheet page)
2 dimensional yes but I won't be going to print it out because it will be a giant mess. I'm going to take the hundredth value and five hundredth value in those thousand lists and add it to some list separate for hundredth list and thousandth list.
February 25th, 2013, 08:39 PM

[[prng()
for c in range(cols)]
for r in range(rows)]
where prng is the random number generator.
[code]
Code tags[/code] are essential for python code and Makefiles!
February 25th, 2013, 09:29 PM

Originally Posted by b49P23TIvg
[[prng()
for c in range(cols)]
for r in range(rows)]
where prng is the random number generator.
Thanks I seem to have got this part! Thank you sir b49P23TIvg!
February 25th, 2013, 10:34 PM

Okay I have gotten the list of values for hundred and five hundred terms. Is there a way to find the times a position is revisited/or similar values(0.001 considered equal).
February 25th, 2013, 11:10 PM

I don't understand "I'm going to take the hundredth value and five hundredth value in those thousand lists and add it to some list separate for hundredth list and thousandth list." Nor do I understand why you'd need to generate all that data to get 2 random numbers.
Sort the data then use your tolerant comparisons across neighbors. You'll have to do this carefully, as Ken Iverson said,
Originally Posted by http://keiapl.org/anec/
In an early talk Ken was explaining the advantages of tolerant comparison. A member of the audience asked incredulously, “Surely you don’t mean that when A=B and B=C, A may not equal C?” Without skipping a beat, Ken replied, “Any carpenter knows that!” and went on to the next question.
[code]
Code tags[/code] are essential for python code and Makefiles!
February 25th, 2013, 11:53 PM

Is there a way to find numbers equal to each other in a list and how many times they occur in a list?
February 26th, 2013, 08:19 AM

>>> dir(list)
.
.
.
>>> help(list.extend)
.
.
.
[code]
Code tags[/code] are essential for python code and Makefiles!
February 26th, 2013, 12:03 PM

I have used list.count(x) function but the code is taking a lot of time to generate the results lol, it still hasn't printed the results.
February 26th, 2013, 12:33 PM

If you first sort the data, then look through it with a histogram sort of approach you'll get O(n log(n)) performance rather than O(n*n) which you get by scanning the entire list n times.
if n is a million, n squared is 72000 times the value of n log(n)
[code]
Code tags[/code] are essential for python code and Makefiles!
March 1st, 2013, 01:54 PM

March 1st, 2013, 02:39 PM

find_three_double works when presented with a list of words.
Code:
>>> find_three_double('bookkeeper axbcccc'.split())
bookkeeper
axbcccc
2 found
>>> find_three_double('bookkeeper axbccc'.split())
bookkeeper
1 found
>>>
Regarding your other question, write some clever logic to avoid whatever it is you mean to avoid.
Note that
Code:
>>> '%%f' % ()
'%f'
[code]
Code tags[/code] are essential for python code and Makefiles!