how to create shapes in python

纯净搜索 为您找到 本页 4 条,用时 3.68 秒(数据源:bingrss)

AI 回答 由 glm-4-flash 生成 · 仅供参考,请自行核实
1. 使用 `matplotlib` 库

import matplotlib.pyplot as plt
import numpy as np

创建圆形
theta = np.linspace(0, 2*np.pi, 100)
x = np.cos(theta)
y = np.sin(theta)
plt.plot(x, y, 'b-')
plt.show()

创建正方形
square_x = [0, 1, 1, 0]
square_y = [0, 0, 1, 1]
plt.plot(square_x, square_y, 'r-')
plt.show()

2. 使用 `turtle` 库

import turtle

创建圆形
turtle.circle(50)
turtle.done()

创建正方形
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.done()

XX-Net

XX-Net is an anti-censorship VPN to by-pass GFW in China.
xx-net.com