def main(args): #print("hello world") r = float(args[0]) if len(args) >= 1 else 1 n = int(args[1]) if len(args) >= 2 else 2000 ep = float(args[2]) if len(args) >= 3 else 0.06 bound = float(args[3]) if len(args) >= 4 else 10 filename = args[4] if len(args) >= 5 else "points.csv" if "test" in args: c = cir.circle(r, n) print(c) p = compute_point(c.eval(40), r) print(p) c = cir.circle(0.9, n) print(c) p = compute_point(c.eval(40), 0.9) print(p) return print("radius: "+str(r)+" number of points: "+str(n)+" epsilon: "+str(ep)+" bound: "+str(bound)) setup_output(filename) c = cir.circle(r, n) last = None for k in range(n): cirpoint = c.eval(k) temp = mapping(cirpoint, c, r, n, ep, bound, last, k) if temp is not None: to_output(temp+[k*2*np.pi/n]) last = temp else: pass
def hf(wl, img): nx, ny = img.shape # m = img.min() # img[img<=m] = 0. # img[img>m] = img[img>m] - m # w = c.circle(256,nx) # w = U.discArray((nx,ny),256) # img = img*w na = 1.2 dp = 1 / (nx * 0.089) radius = (na / wl) / dp msk = c.circle(1.8 * radius, nx) - c.circle(0.1 * radius, nx) # msk = U.discArray((nx,nx),1.8*radius) - U.discArray((nx,nx),0.1*radius) lp = gaussianArr(shape=(nx, nx), sigma=0.8 * radius, peakVal=1, orig=None, dtype=np.float32) hp = 1 - gaussianArr(shape=(nx, nx), sigma=0.8 * radius, peakVal=1, orig=None, dtype=np.float32) aft = fftshift(fft2(img)) aft = aft * (msk * lp * hp) res = (np.abs(aft)).sum() return res
def start(self): random.seed() self.x_off = 4 self.y_off = 4 self.speed = 0.01 self.speed_off = random.uniform(0.01, 0.05) for i in range(0, len(self.x_circs)): self.x_circs[i] = circle(self.circ_radius, self.circ_radius * 2 * (i + self.x_off), 50, 0, self.speed + self.speed_off, self.width, self.height) self.x_circs[i].show(self.canvas) self.x_off += 0.2 self.speed += self.speed_off self.y_circs[i] = circle(self.circ_radius, 50, self.circ_radius * 2 * (i + self.y_off), 0, self.speed + self.speed_off, self.width, self.height) self.y_circs[i].show(self.canvas) self.speed += self.speed_off self.y_off += 0.2 for i in range(0, len(self.x_circs)): for j in range(0, len(self.y_circs)): self.x_circs[i].show_line(self.canvas, self.y_circs[j])
def test_ls_(): test_circle1 = circle(2) test_circle2 = circle(4) assert ((test_circle1 > test_circle2) is False) is True assert ((test_circle1 < test_circle2) is True) is True assert ((test_circle1 == test_circle2) is False) is True test_circle3 = circle(4) assert ((test_circle3 == test_circle2) is True) is True
def smile(): turtle.shape("turtle") turtle.width(3) turtle.color('yellow') turtle.begin_fill() circle() turtle.end_fill() turtle.left(90) turtle.penup() turtle.forward(140) turtle.left(90) turtle.forward(30) turtle.right(90) turtle.pendown() turtle.color('blue') turtle.begin_fill() for i in range(90): turtle.forward(2) turtle.left(4) turtle.end_fill() turtle.penup() turtle.right(90) turtle.forward(60) turtle.left(90) turtle.pendown() turtle.begin_fill() for j in range(90): turtle.forward(2) turtle.right(4) turtle.end_fill() turtle.color('black') turtle.penup() turtle.left(90) turtle.forward(30) turtle.left(90) turtle.forward(30) turtle.pendown() turtle.width(7) turtle.forward(40) turtle.penup() turtle.forward(45) turtle.pendown() turtle.left(90) turtle.width(3) turtle.color('red') for m in range(80): turtle.forward(1) turtle.left(1) for t in range(160): turtle.backward(1) turtle.right(1) for n in range(80): turtle.forward(1) turtle.left(1) pass
def test_relationships(): c1 = circle(10) c2 = circle(20) assert (c1 > c2) is False assert c1 < c2 assert (c1 == c2) is False c2 = circle(25) assert c1 < c2 c2 = circle(10) assert c1 == c2
def GetAberration2img(self, baseimg, offsetimg, method=1): # initialize Arrays self.nx = self.diameter self.ny = self.diameter self.im = N.zeros( (2, 2 * self.hsp * self.diameter, 2 * self.hsp * self.diameter)) self.gradxy = N.zeros((2, self.diameter, self.diameter)) self.gradx = N.zeros((self.ny, self.nx)) self.grady = N.zeros((self.ny, self.nx)) # self.findcenter(baseimg, offsetimg) # self.hudgins_prep() if (method == 0): print('Correlation') # baseimg = self.suback(baseimg) # offsetimg = self.suback(offsetimg) gradx, grady = self.GetGradientsCorr(baseimg, offsetimg) self.gradxy[0] = self.gradx self.gradxy[1] = self.grady if (method == 1): print('CenterOfMass') baseimg = baseimg / baseimg.max() offsetimg = offsetimg / offsetimg.max() # baseimg = self.suback(baseimg) # offsetimg = self.suback(offsetimg) self.gradx, self.grady = self.GetGradientsCom(baseimg, offsetimg) self.gradxy[0] = self.gradx self.gradxy[1] = self.grady self.extx, self.exty = self.hudgins_extend_mask0( self.gradx, self.grady) self.phi = self.recon_hudgins(self.extx, self.exty) self.phi = self.phi * self.calfactor self.phicorr = self.RemoveGlobalWaffle(self.phi) self.msk = c.circle(self.diameter / 2., self.diameter) self.phicorr = self.phicorr * self.msk return self.phicorr
def zernike_nm(n, m, N): """ Creates the Zernike polynomial with radial index, n, and azimuthal index, m. Args: j (int): The noll j number of the zernike mode N (int): The diameter of the zernike more in pixels Returns: ndarray: The Zernike mode """ coords = numpy.linspace(-1, 1, N) X, Y = numpy.meshgrid(coords, coords) R = numpy.sqrt(X**2 + Y**2) theta = numpy.arctan2(Y, X) if m == 0: Z = numpy.sqrt(n + 1) * zernikeRadialFunc(n, 0, R) else: if m > 0: # j is even Z = numpy.sqrt(2 * (n + 1)) * zernikeRadialFunc( n, m, R) * numpy.cos(m * theta) else: #i is odd m = abs(m) Z = numpy.sqrt(2 * (n + 1)) * zernikeRadialFunc( n, m, R) * numpy.sin(m * theta) return Z * circle(N / 2., N)
def get_circle_in_plane(spheres, zplane): spheres_in_plane = [] for s in spheres: r = s.get_radius() c = s.get_center() cx = c.get_x() cy = c.get_y() cz = c.get_z() if (zplane >= (cz - r)) and (zplane <= (cz + r)): spheres_in_plane.append(s) circles = [] for s in spheres_in_plane: r = s.get_radius() c = s.get_center() cx = c.get_x() cy = c.get_y() cz = c.get_z() circler = math.sqrt(math.pow(r, 2) - math.pow((zplane - cz), 2)) cir = circle.circle(cx, cy, circler) circles.append(cir) return circles
def snr(wl, img, lpr, hpr): nx, ny = img.shape m = img.min() img[img <= m] = 0. img[img > m] = img[img > m] - m # w = U.discArray((nx,ny),256) # img = img*w na = 1.2 dp = 1 / (nx * 0.089) radius = (na / wl) / dp msk = c.circle(2.0 * radius, nx) siglp = radius * 0.1 sighp = radius * 0.4 lp = gaussianArr(shape=(nx, nx), sigma=siglp, peakVal=1, orig=None, dtype=np.float32) hp = 1 - gaussianArr( shape=(nx, nx), sigma=sighp, peakVal=1, orig=None, dtype=np.float32) aft = fftshift(fft2(img)) hpC = (np.abs(hp * aft * msk)).sum() lpC = (np.abs(lp * aft * msk)).sum() res = hpC / lpC return res
def peakv(img): nx, ny = img.shape w = c.circle(64, nx) # w = U.discArray((nx,ny),64) img = img * w maxv = img.max() return maxv
def getPoints(self, curTime): t = datetime.now() out = [] center = Point(self.x, self.y) circ = circle(self.x, self.y, self.r, 50) circleStart = circ[0] out.extend(circ) out.extend(dwell(circleStart, 4)) out.extend(dwell(circleStart.withColor(0), 6)) out.extend(slirp(circleStart, center, 10, 0)) second = t.second + (t.microsecond / 1000000.0) minute = t.minute + (second / 60.0) hour = t.hour + (minute / 60.0) #print "hms", hour, minute, second out.extend(dwell(center.withColor(0), 6)) out.extend(self.getHand(second, 60, .9)) out.extend(self.getHand(minute, 60, .75)) out.extend(self.getHand(hour, 12, .5)) out.extend(slirp(center, circleStart, 10, 0)) out.extend(dwell(circleStart.withColor(0), 3)) return out
def main(): root = Tk() # ルートフレームの作成 canvas = Canvas(root, width=W, height=H, bg='black') # canvasの作成 canvas.pack() # canvasの配置確定 points = circle.circle() display(canvas, points) # 描画関数 (display) の呼出 root.mainloop() # ルートフレームの実行ループ開始
def test_diameter(): test_circle = circle(4) assert (test_circle.diameter == 8) is True assert (test_circle.radius == 4) is True # Test Step 3 test_circle.diameter = 16 assert (test_circle.diameter == 16) is True assert (test_circle.radius == 8) is True
def circumcircle(self): #This method returns the smallest circumcircle of the edge object and makes the circumcircle object a singleton. if self.circumCircle is None: self.circumCircle = circle( point((self.points[0].x + self.points[1].x) / 2, (self.points[0].y + self.points[1].y) / 2), math.sqrt((self.points[1].x - self.points[0].x)**2 + (self.points[1].y - self.points[0].y)**2) / 2) return self.circumCircle
def main(): root = Tk() # ルートフレームの作成 canvas = Canvas(root, width=W, height=H, highlightthickness=0) # canvasの作成 canvas.pack() # canvasの配置確定 points = circle.circle() circle.display(canvas, points) display(canvas, points) # 描画関数 (display) の呼出 root.mainloop() # ルートフレームの実行ループ開始
def main(): # define your portfolio + labels (from high to low about your proportion) """ examples my_portfolio = {'bitcoin': 1, 'ethereum' : 1} labels = ['BTC', 'ETH'] """ portfolio = # portfolio labels = # labels my_growth_rate, num_for_pie, total_outcome = arange_total_asset(portfolio, labels) # principal, portfolio fig1 = circle(my_growth_rate, num_for_pie, labels, total_outcome) fig_line = line_time(portfolio, ) # portfolio, year, month, date plt.show()
def __init__(self, position, speed, color, lives): self.width, self.height = 9.5, 8.5 #Width, Height self.position = [] self.position.append(float(position[0])) self.position.append(float(position[1])) self.speed = (float(speed[0]), float(speed[1])) self.color = color self.health = 100.0 self.lives = lives #number of lives self.outLine = circle.circle(position, 5, color, 2) #Outline of the ship
def getClosestCircle(self, points): furthest_points = self.getFurthestPoints(points) # get average circle center c = np.mean(0.5 * (np.add(points, furthest_points)), axis=0) # get average radius r = 0.5 * np.mean( np.sqrt( np.sum(np.square(np.subtract(points, furthest_points)), axis=1))) return circle.circle(None, None, c, r)
def select_wedge(image, feature, axis, color): center = (halfwidth, halfwidth) guess = np.mean(np.linalg.norm(feature - center, axis=1)) fit = curve_fit(circle, feature[:, 0], (feature[:, 1] - halfwidth)**2, p0=[guess]) rad = fit[0] yfit = np.sqrt(circle(feature[:, 0], rad)) + halfwidth print(rad) #note - if you do imshow(image), you do scatter(y, x) for things to line up #how does this affect wedges? try: thetas = np.rad2deg(np.arcsin( (feature[:, 1] - center[0]) / rad)) - 90 #because of limits of arcsin output w1 = patches.Wedge(center, 2 * rad, np.nanmin(thetas), np.nanmax(thetas)) if sum([ w1.contains_point(point) for point in feature ]) == 0: #because adding 180deg maintains sin and flips sign of cos w1 = patches.Wedge(center, 2 * rad, np.nanmin(thetas) + 180, np.nanmax(thetas) + 180) X, Y = np.mgrid[0:image.shape[1], 0:image.shape[0]] in_wedge = np.array([ w1.contains_point(point) for point in np.vstack((X.ravel(), Y.ravel())).T ]).reshape(image.shape) wedge = image * in_wedge wedge[wedge == 0] = np.nan profile = radial_profile(wedge, center) # print(profile) axis.plot(np.arange(len(profile)), profile, label="%0.1f kpc" % rad, color=color) axis.vlines(rad, 0, np.nanmax(profile), color=color, linestyle='dashed') axis.set_ylim(np.nanmin(profile), np.nanmax(profile)) axis.legend() print("Wedge made") return wedge except ValueError: print("This feature isn't an arc")
def get_circle_points_list(x, y, circles): poly_data_points = [] # x , y e' il primo punto cell retta # per generare i secondi punti della circonferenza uso circle point_circle = circle.circle(x, y, 1.0) second_points = point_circle.generate_circle_points(NUMOFCIRCLEPOINTS) #print len(second_points) for pi in second_points: l = line.line2d() l.set_two_point([x, y], pi) ref_quadrant = get_quadrant_respect_to(pi, [x, y]) #print "quadrant: ", ref_quadrant closet_point = [x, y] closet_point_min_d = float("inf") for cir in circles: int_points = circle.line_circle_intersection(cir, l) selected_point = [x, y] min_distance = float("inf") for ip in int_points: if (get_quadrant_respect_to(ip, [x, y]) == ref_quadrant): d = point_distance(ip, [x, y]) if (d > 0.0): if (d < min_distance): min_distance = d selected_point = ip d = point_distance(selected_point, [x, y]) if d > 0.0: if (d < closet_point_min_d): closet_point_min_d = d closet_point = selected_point if point_distance(closet_point, [x, y]) > 0.0: poly_data_points.append(closet_point) return poly_data_points
def circumcircle(self): #This method computes the circumcircle of the triangle object and makes the circumcircle variable a singleton. if self.circumCircle is None: Sx=npla.det([[self.points[0].x**2+self.points[0].y**2,self.points[0].y,1], [self.points[1].x**2+self.points[1].y**2,self.points[1].y,1], [self.points[2].x**2+self.points[2].y**2,self.points[2].y,1]])/2 Sy=npla.det([[self.points[0].x,self.points[0].x**2+self.points[0].y**2,1], [self.points[1].x,self.points[1].x**2+self.points[1].y**2,1], [self.points[2].x,self.points[2].x**2+self.points[2].y**2,1]])/2 a=npla.det([[self.points[0].x,self.points[0].y,1], [self.points[1].x,self.points[1].y,1], [self.points[2].x,self.points[2].y,1]]) b=npla.det([[self.points[0].x,self.points[0].y,self.points[0].x**2+self.points[0].y**2], [self.points[1].x,self.points[1].y,self.points[1].x**2+self.points[1].y**2], [self.points[2].x,self.points[2].y,self.points[2].x**2+self.points[2].y**2]]) self.circumCircle=circle(point(Sx/a,Sy/a),math.sqrt(b/a+(Sx**2+Sy**2)/a**2)) return self.circumCircle
def zernikeArray(J, N, norm="noll"): """ Creates an array of Zernike Polynomials Parameters: maxJ (int or list): Max Zernike polynomial to create, or list of zernikes J indices to create N (int): size of created arrays norm (string, optional): The normalisation of Zernike modes. Can be ``"noll"``, ``"p2v"`` (peak to valley), or ``"rms"``. default is ``"noll"``. Returns: ndarray: array of Zernike Polynomials """ # If list, make those Zernikes try: nJ = len(J) Zs = numpy.empty((nJ, N, N)) for i in xrange(nJ): Zs[i] = zernike(J[i], N) # Else, cast to int and create up to that number except TypeError: maxJ = int(numpy.round(J)) N = int(numpy.round(N)) Zs = numpy.empty((maxJ, N, N)) for j in xrange(1, maxJ + 1): Zs[j - 1] = zernike(j, N) if norm == "p2v": for z in xrange(len(Zs)): Zs[z] /= (Zs[z].max() - Zs[z].min()) elif norm == "rms": for z in xrange(len(Zs)): # Norm by RMS. Remember only to include circle elements in mean Zs[z] /= numpy.sqrt( numpy.sum(Zs[z]**2) / numpy.sum(circle(N / 2., N))) return Zs
valid_LEDs, color, blob_size, valid_cluster_index = CLTR.Clusters(LEDs, indices, color, blob_size)#, img, SHOW_NEIGHBORS) # print valid_cluster_index centers = [] LEDs_per_Ebug = [] LEDColor_per_Ebug = [] BlobSize_per_Ebug = [] radius = [] visited = [] ID = [] for i in valid_cluster_index: if i in visited: continue visited.append(i) buf_LEDs = valid_LEDs[np.where(valid_cluster_index == i)] circle_LEDs = CL.circle(buf_LEDs) center = np.array(list(map(int, circle_LEDs.LS()))) bad_est = False if 1: # not centers: centers.append(center) LEDs_per_Ebug.append(buf_LEDs) radius.append(int(circle_LEDs.calc_R(*center).mean())) LEDColor_per_Ebug.append(color[np.where(valid_cluster_index == i)]) BlobSize_per_Ebug.append(blob_size[np.where(valid_cluster_index == i)]) """ else: for j in range(len(centers)): if ((centers[j]-centers)**2).sum()<10: bad_est = True if len(LEDs_per_Ebug[j])>=len(buf_LEDs):
# classes.py # Exemple playing with Python classes # 2015-05-06 PV from circle import circle c = circle(3.0, 4.0, 5.0) print("Surface:", round(c.surface(), 2)) class ellipse(circle): """A variation over circle""" def __init__(self, x, y, rx, ry): super().__init__(x, y, rx) # Don't pass self in this case! self.ry = ry def surface(self): return super().surface() / self.r * self.ry # Ellipse half of the surface of the previous circle e = ellipse(3.0, 4.0, 5.0, 2.5) print("Surface:", round(e.surface(), 2))
def init(): pygame.init() clock = pygame.time.Clock() circles = {} circles["x"] = {} circles["y"] = {} circles["pixel"] = {} myfont = pygame.font.SysFont("arial", 14) myfont.set_bold(True) pygame.mouse.set_visible(1) pygame.key.set_repeat(1, 1) pygame.display.set_caption("Loading...INIT") screen = pygame.display.set_mode((1000, 1000)) running = True for x in range(1, 15): circles["x"][x] = circle.circle(50, (100, 100, 100), 2 * x) circles["x"][x].tick_surface() for y in range(1, 15): circles["y"][y] = circle.circle(50, (100, 100, 100), 2 * y) circles["y"][y].tick_surface() for x in circles["x"]: circles["pixel"][x] = {} for y in circles["y"]: circles["pixel"][x][y] = circle.points(circles["x"][x], circles["y"][y], 50, (100, 100, 100)) while running: events = pygame.event.get() for event in events: mousepos = pygame.mouse.get_pos() mouseposx = int(mousepos[0] / 10) mouseposy = int(mousepos[1] / 10) # Spiel beenden, wenn wir ein QUIT-Event finden. if event.type == pygame.QUIT: print("pressed exit") #p.terminate() pygame.display.quit() running = False break time = clock.get_time() for x in circles["x"]: circles["x"][x].set_time(time) for y in circles["y"]: circles["y"][y].set_time(time) for x in circles["pixel"]: for y in circles["pixel"][x]: circles["pixel"][x][y].draw_pixel() if running is True: pygame.display.set_caption(str(int(clock.get_fps()))) screen.fill((0, 0, 0)) for x in circles["x"]: screen.blit(circles["x"][x].draw(), (60 * x, 0)) for y in circles["y"]: screen.blit(circles["y"][y].draw(), (0, 60 * y)) for x in circles["pixel"]: for y in circles["pixel"][x]: screen.blit(circles["pixel"][x][y].draw(), (x * 60, y * 60)) clock.tick(30) pygame.display.flip()
def flower(): turtle.shape('turtle') for i in range(20): circle() turtle.left(8) pass
import operator import MODE import threading screen = pygame.display.set_mode((1024, 768)) mode=MODE.general clock = pygame.time.Clock() myskyper = skyper('xaxamy') circles=[] data = myskyper.getData() t=threading.Thread(target=myskyper.parseData) t.daemon=True t.start() WHITE = (255, 255, 255) circles.append(circle(512, 384, 40, 'YOU')) maxkey = max(data.iteritems(), key=operator.itemgetter(1))[0] ratio = 60 / data[maxkey] for d in data: data[d] = data[d] * ratio index = 0 print data for d in data: x = int(512 + math.cos(index * 2 * math.pi / len(data)) * 300) y = int(368 + math.sin(index * 2 * math.pi / len(data)) * 300) circles.append(circle(x, y, int(data[d]), d)) index = index + 1 pygame.init() while 1:
window = pygame.display.set_mode((width, height)) pygame.font.init() pygame.display.set_caption("Connect 4") #bigger font myfont = pygame.font.SysFont("Comic Sans MS", 50) #smaller font myfont1 = pygame.font.SysFont("Comic Sans MS", 30) #even smaller font font2 = pygame.font.SysFont("Comic Sans MS", 20) red = False yellow = False a = [[circle(255, 255, 255, 100, 100) for c in range(7)] for r in range(6)] color = (255, 0, 0) pos = (100, 100) play = True instruct = True #checks that r and c values given don't exceed array boundries def inRange(r, c): if r > -1 and r < len(a) and c > -1 and c < len(a[r]): return True return False
def get_robot_position(ts, camera): try: prev_ts = ts ts, blobs_list = camera.get_blobs() LED_positions = [] LED_position_buffer = [] LED_colors_buffer = [] blob_size_buffer = [] frame_times = list(zip(list(range(10)), list(range(10)))) if ts != prev_ts: for blob in blobs_list: # A blob contains one lED position x_coord = blob[0] y_coord = blob[1] color = blob[2] radius = blob[3] LED_position_buffer.append([x_coord / 2, y_coord / 2]) LED_colors_buffer.append(color) blob_size_buffer.append(int(radius / sqrt(pi) / 2) * 2) LED_positions = np.array(LED_position_buffer) LED_colors = np.array(LED_colors_buffer) blob_sizes = np.array(blob_size_buffer) if len(LED_positions) > 5: # Find the closest neighbors of each LED_positions neigh = NearestNeighbors( n_neighbors=4, algorithm='ball_tree').fit(LED_positions) distances, indices = neigh.kneighbors(LED_positions) index_true = [] index_false = [] for i in range(len(distances)): if indices[i][0] in index_false: continue bad_group = [] for j in range(1, 4): if distances[i][j] < 6: bad_group.append(indices[i][j]) index_true += [indices[i][0]] index_false += bad_group LED_positions = LED_positions[list(set(index_true))] if len(LED_positions) > 3: LED_colors = LED_colors[list(set(index_true))] blob_sizes = blob_sizes[list(set(index_true))] nbrs = NearestNeighbors( n_neighbors=3, algorithm='kd_tree').fit(LED_positions) indices = nbrs.kneighbors(LED_positions, return_distance=False) # Group LEDs in order to create ebugs valid_LEDs, LED_colors, blob_sizes, valid_cluster_index = Clusters( LED_positions, indices, LED_colors, blob_sizes) centers = [] LEDs_per_Ebug = [] LEDColor_per_Ebug = [] BlobSize_per_Ebug = [] radius = [] visited = [] ID = [] for i in valid_cluster_index: if i in visited: continue visited.append(i) buf_LEDs = valid_LEDs[np.where( valid_cluster_index == i)] circle_LEDs = CL.circle(buf_LEDs) center = np.array(list(map(int, circle_LEDs.LS()))) bad_est = False centers.append(center) LEDs_per_Ebug.append(buf_LEDs) radius.append(int(circle_LEDs.calc_R(*center).mean())) LEDColor_per_Ebug.append( LED_colors[np.where(valid_cluster_index == i)]) BlobSize_per_Ebug.append( blob_sizes[np.where(valid_cluster_index == i)]) for i in range(len(radius)): color_seq, blob_seq = CL.GetSequence( LEDs_per_Ebug[i], LEDColor_per_Ebug[i], BlobSize_per_Ebug[i], centers[i], radius[i], 16) EbugID = CL.EbugIdDtection(color_seq, LED_DETECTION_THRESHOLD) if EbugID != -1: ID.append(EbugID) ebugs_list = [] for i in range(len(ID)): ebug = { "Name": ID[i], "Center": centers[i], "Radius": radius[i] } ebugs_list.append(ebug) print("Ebugs data :", ebugs_list) return ebugs_list return None except RuntimeError as e: print('Error received : ', e) pass
# ---------main---------------------- flag = True while flag: print("1. круг") print("2. квадрат") print("3. прямоугольник") print("0. выход") WhatTheFigure = change("") if (WhatTheFigure == 1): R = 0 while R <= 0: try: R = change("Введите радиус круга: ") func1 = lambda R: print("площадь круга равна " + str( circle.circle(R).reckon())) if R > 0 else print( "Радиус круга должен быть больше 0") func1(R) except ValueError: print('неверный формат строки') R = 0 if (WhatTheFigure == 2): L = 0 while L <= 0: try: L = change("Введите длину стороны: ") func2 = lambda L: print( "площадь квадрата равна: " + square.square(R).reckon() ) if L > 0 else print("Длина стороны должна быть больше 0") func2(L)
def border(self): self.display = circle.circle(self.display, (self.size/2,self.size/2), (self.size/2)-1)
def circle(self, start, radius, color): self.display = circle.circle(self.display, start, radius, color=color)