I have been learning Java since September, but have been given an assignment for a science course by a professor to create a program in Python that will generate a random diameter using a max and minimum value, and 15 random points within this sphere (x, y, z).
I need to make a random number generator that generates a number between 0.0 and 1.0 so I can plug it into my formula to find a random diameter. If the random number is RN, it would be: [(RN*(max-min))+min]
At first I used this random function:
from random import*
RN=random():
The problem is, this random function is [0.0, 1.0). In other words, it does not include 1.0. How can I create a function that includes 1.0?
Also, if you don't mind, can you help me with finding the y and z coordinates? I know how to find x.
The formula for the y value is y=+ or - sqrt(r^2-x^2) (to be randomly generated too). I would have the x value, which is the result from the random function [0.0-1.0], and the radius which would be half my diameter. I am a complete beginner at Python, how do I initialize my x and y and put the above formula in?
The formula for z is similar, z=+ or - sqrt(-x^2-y^2+r^2) (to be randomly generated as well)
These are using the formulas for a circle: radius: r=sqrt(x^2+y^2) sphere:r=sqrt(x^2+y^2+z^2)
I would be incredibly grateful if you could answer any part of my question, thank you so much for taking the time to read this!! **by the way, I am usinHi! I have been learning Java since September, but have been given an assignment for a science course by a professor to create a program in Python that will generate a random diameter using a max and minimum value, and 15 random points within this sphere (x, y, z).
I need to make a random number generator that generates a number between 0.0 and 1.0 so I can plug it into my formula to find a random diameter. If the random number is RN, it would be: [(RN*(max-min))+min]
At first I used this random function:
from random import* RN=random():
The problem is, this random function is [0.0, 1.0). In other words, it does not include 1.0. How can I create a function that includes 1.0?
Also, if you don't mind, can you help me with finding the y and z coordinates? I know how to find x.
The formula for the y value is y=+ or - sqrt(r^2-x^2) (to be randomly generated too). I would have the x value, which is the result from the random function [0.0-1.0], and the radius which would be half my diameter. I am a complete beginner at Python, how do I initialize my x and y and put the above formula in?
The formula for z is similar, z=+ or - sqrt(-x^2-y^2+r^2) (to be randomly generated as well)
These are using the formulas for a circle: radius: r=sqrt(x^2+y^2) sphere:r=sqrt(x^2+y^2+z^2)
I would be incredibly grateful if you could answer any part of my question, thank you so much for taking the time to read this!!!
**by the way, I am using python x,y spyder!