Page 1 of 2 12 Last
1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Feb 2013
Posts
9
Rep Power
0

#### For loops question.

Thank you for the hint!
2. 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))```
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Feb 2013
Posts
9
Rep Power
0
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?
4. Are you trying to get a matrix of random numbers?

(2 dimensional, like a populated spreadsheet page)
5. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Feb 2013
Posts
9
Rep Power
0
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.
6. [[prng()
for c in range(cols)]
for r in range(rows)]

where prng is the random number generator.
7. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Feb 2013
Posts
9
Rep Power
0
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!
8. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Feb 2013
Posts
9
Rep Power
0
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).
9. 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.
10. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Feb 2013
Posts
9
Rep Power
0
Is there a way to find numbers equal to each other in a list and how many times they occur in a list?
11. >>> dir(list)
.
.
.
>>> help(list.extend)
.
.
.
12. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Feb 2013
Posts
9
Rep Power
0
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.
13. 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)
14. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Feb 2013
Posts
9
Rep Power
0
thanks!
15. 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'```
Page 1 of 2 12 Last