Hi everyone, I'm fairly new with python and as such am playing around alot with just basic coding/scripting. I've spent the better part of today working with random numbers. Thanks for all your comments and advice it's really helped me to learn. I have a new question that I an thinking about right now, I have an idea of how to proceed but wanted to pose this question to get some advice.
Here is what I am trying to do and what I have figured out so far.
Now I know this is not the correct script but this is what I've got so far any advice/help would be greatly appreciated thanks everyone.
Sincerely,
Deathwing
Here is what I am trying to do and what I have figured out so far.
- I then want the script to generate random numbers that are with the bounds of the "upper left and lower right" vectors/coordinates
- So, basically none of the randomly generated decimal numbers can go out of the bounds of the "upper left and lower right" coordinates.
- So far by playing around I have coded the following thanks to the knowledge gained from the help of others on this forum.
Code:
import random f = open(r "ni.txt", "w" ) #defining num function def num(n): x,y = 150,200 whil n < x and n < y: n += 1 f.writelines(["%10.4f %10.4f\n" % (random.random()*random.randrange(1,35),random.random()*random.randrange(1,35))]) # calling function num num(random.randrange(1)) f.close raw_input("\nPress ENTER to exit") #----------------------------------------- # output generated #----------------------------------------- 10.8011 7.2231 7.1643 27.9521 9.6282 1.6043 0.2221 33.7514 8.5689 11.9781 14.6153 5.3605 21.9485 8.3382 2.7590 12.3986 0.5102 2.3836 1.3386 19.3828 0.9377 0.4229 1.6024 1.5889 8.4589 4.4812 29.6486 3.9461 12.8277 3.5010 22.9659 4.1116 17.1734 17.1360 7.3082 1.6732 0.8224 0.2964 1.0680 5.9264 8.6494 3.6651 7.1057 5.5809 2.4803 10.0084 6.0981 7.9107 2.0459 2.5169 3.9406 13.4154 0.2515 7.6117 6.7652 28.2090 11.9972 9.7133 12.6741 10.6329 28.5646 6.6041 5.0474 3.1988 1.8366 17.3606
Sincerely,
Deathwing
Comment