00:01
For problem 39, you want to write a program that will ask a user to input the x and y coordinates as well as the radius for two circles.
00:12
And then it will determine whether or not those circles overlap if circle two is inside circle one or if they do not overlap.
00:21
And it will draw the circles and display the result.
00:25
So this is very similar to problem 29 in chapter four.
00:31
With some new additions, meaning that you just have to draw everything out.
00:36
So we'll import math and turtle.
00:39
Just like in problem 29, we'll assign x, 1, y, 1, and r1 to the center and radius of circle 1, and x2, y, 2, and r2 to the center and radius of circle 2.
00:53
We need to draw the two circles.
00:56
So we'll use turtle to do that by picking up the pen, going to, i chose to go to x2, x1 minus y or x1, y1 minus r.
01:05
Put the pen down and draw a circle of radius r1.
01:09
Pick up the pen, go to x2, y2 minus r2.
01:14
Put the pen down and again, draw a circle of radius r2.
01:17
Because i noticed that when turtle draws circles, it typically starts from the bottom of the circle and then goes around counterclockwise.
01:30
Then we need to display the status.
01:33
So we'll pick up the pen.
01:34
I just decided to go to x1 minus 70, y1 minus 50.
01:38
So it's at some location that is not overlapping with the circles most likely and put down the pen.
01:45
And then we'll use the same conditional that we used in problem 29.
01:50
So we'll first find the distance between the two centers.
01:55
If that distance is less than or equal to the absolute value of r1 minus r2, then we know circle two is inside circle one, so we'll have turtle write that...