Randomness

Example: Random Concentric Circles

random concentric circles

Example: Random Touching Circles

random touching circles

Exercises

Problem 4.1 Write a program to draw 100 circles at random locations with random size.

random circles

Problem 4.2 Write a program to draw concentric circles of random size.

random circles

Problem 4.3 Can you place the random concentric circles drawn in the above problem in grid?

random circles in a grid

Problem 4.4 Write a program that draws one of the two diagonals in random for each cell of a 4x4 grid. The grid is shown with a light color in the picture for your refefence and you don’t need to draw it.

rand10

Try changing the grid size to 16x16 or 32x32.