Question: PYTHON PLEASE!!! Open a Python graphics window (size 400 x 400) and use randrange() to randomly generate points. Make two calls to randrange for each
PYTHON PLEASE!!!
Open a Python graphics window (size 400 x 400) and use randrange() to randomly generate points. Make two calls to randrange for each point. The first call should generate the x value and the second call should generate the y value. Put this into a loop that cycles through 10,000x and verify that all the points are within the window.
Now add color to the points. If a point is within 50 pixels of the center, make it red. If its between 50 and 100, make it blue. If its between 100 and 150, make it yellow. Lastly, if its between 150 and 200, make it green. You should have enough points to make out what appear to be concentric circles.
Anser for the 1st part is:
from graphics import * import random
def plotPoints(win, pts): for i in range(pts): p1=Point(random.randrange(0, win.width), random.randrange(0, win.height)) p1.draw(win)
def main (): win=GraphWin("My Window", 400, 400) win.setCoords(0, 0, 400, 400) win.width=400 win.height=400
plotPoints(win, 10000) win.getMouse() win.close()
main()
Now add color to the points. If a point is within 50 pixels of the center, make it red. If its between 50 and 100, make it blue. If its between 100 and 150, make it yellow. Lastly, if its between 150 and 200, make it green. You should have enough points to make out what appear to be concentric circles.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
