According to the following code. Which option is showing the correct way of creating a list of 10 Circle Objects?
class Point:
def __init__(self,x,y):
self.x = x
self.y = y
class Circle:
def __init__(self,p1,rad):
self.p = p
self.radius = rad
Question 7 options:
None of the options
circles = []
for i in range(10):
point = Point(random.randint(1,100),random.randint(1,100))
circles.append(Circle(point, random.randint(1,10)))
circles = []
for i in range(10):
circle = Point(random.randint(1,100),random.randint(1,100))
circles.append(circle)
for i in range(10):
circle = Point(random.randint(1,100),random.randint(1,100))
circles.append(circle)
The correct way of creating a list of 10 Circle Objects in this case is the first option:
```python
circles = []
for i in range(10):
point = Point(random.randint(1,100),random.randint(1,100))
circles.append(Circle(point, random.randint(1,10)))
```
In this option, a list called `circles` is initialized as an empty list. Then, a `for` loop is used to iterate 10 times. Inside the loop, a new `Point` object is created with random coordinates using the `random.randint()` function. Then, a new `Circle` object is instantiated using the `Point` object and a random radius. Finally, the newly created `Circle` object is appended to the `circles` list.
The other two options are incorrect because they don't create `Circle` objects and append them to the `circles` list correctly. In the second option, only a `Point` object is created and appended, without creating a corresponding `Circle` object. In the third option, a `Point` object is created and appended, but the variable name `circle` is used instead of `circles` when appending to the list, causing an error.