The following link may help you with the while loop: http://www.pythonforbeginners.com/loops/...ile-loops/
Please note that Python is CASE SENSITIVE.
In your existing code, For should be for. According to the Python style guide (PEP8) randx and randy should be lower case. See https://www.python.org/dev/peps/pep-0008/ See the 'function and variable names section': https://www.python.org/dev/peps/pep-0008...able-names
You should probably add a debugging print statement to see if your code is working correctly. Maybe something like:
Lewis
Please note that Python is CASE SENSITIVE.
In your existing code, For should be for. According to the Python style guide (PEP8) randx and randy should be lower case. See https://www.python.org/dev/peps/pep-0008/ See the 'function and variable names section': https://www.python.org/dev/peps/pep-0008...able-names
You should probably add a debugging print statement to see if your code is working correctly. Maybe something like:
print(randx, randy, randx**2+randy**2, hits)When testing code with random numbers, it is sometimes difficult to debug the code because each time you run the code, the random number sequence is different. For testing purposes you can add the following line at the beginning of your code (after the import statement) to generate the same random number sequence each time. The number inside the parentheses is the 'seed number' which you can change to any number you like. When you are done debugging, you can remove the line that seeds the random number generator.
random.seed(12345)I hope this helps.
Lewis
To paraphrase: 'Throw out your dead' code. https://www.youtube.com/watch?v=grbSQ6O6kbs Forward to 1:00