2.1 KiB
2.1 KiB
In [ ]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
Vectorize this code
In [ ]:
size = 101
center = size // 2
radius = 20
circle = np.zeros((size, size), dtype=float)
for i in range(size):
for j in range(size):
distance_from_center = np.sqrt((i - center)**2 + (j - center)**2)
if distance_from_center <= radius:
circle[i, j] = 1
In [ ]:
plt.imshow(circle)
Solution¶
In [ ]:
# type your solution here
In [ ]:
In [ ]:
In [ ]: