Question: Here are the specifications for this problem: Use a 5 0 0 x 5 0 0 canvas. Usually the canvas size is pretty arbitrary, but

Here are the specifications for this problem:
Use a 500x500 canvas. Usually the canvas size is pretty arbitrary, but this time it will be important to
demonstrate your understanding of this problem.
Draw the head and body of the lady bug. You are free to add more details to the drawing if you like,
so long as you are still meeting the criteria outlined here.
Use a while-loop to draw N small black spots (circles of diameter 50) on the bug. The example above
uses N of 10, but your program should work for any value of N . It is okay if the circles sometimes
overlap with each other, but they should all be completely on the bug.
Heres the trick: your spots need to be at random locations. To generate random coordinates for a single
spot, use these two lines of code:
x = int ( random (0,500))
y = int ( random (0,500))
The random() function simply returns a random number within the specified bounds, so in this case, x
and y will be random coordinates on your 500x500 canvas. The problem is that the bug doesnt fill the
whole canvas, so sometimes the random coordinates will be no good. That simply means youll have to not draw a spot at those coordinates and try again. Thats why you need to use a while-loop for this problem,
because you dont know how long it will take to generate valid coordinates for N spots on the bug 1
Hint: Make sure to take the diameter/radius of the holes into account when checking if the random coor-
dinates are valid; your holes need to be *completely* on the bug!
Hint: You can use your code (or the solution code) for inside_circle() from A3 to help you do this check

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!