❶ 如何用python画同心圆并内接一个五角星
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
theta = np.linspace(0, 2* np.pi, 100)
r, R = 9, 10 # 小圆和大圆的半径
# outter circle
X = R * np.cos(theta)
Y = R * np.sin(theta)
# innner circle
x = r * np.cos(theta)
y = r * np.sin(theta)
# pentagon vertices
p_theta = [np.pi/2 + np.pi*4/5 * i for i in range(6)] # 五角星的定点.
px = r * np.cos(p_theta)
py = r * np.sin(p_theta)
# plot
plt.plot(X, Y, label='Big Circle', color='blue')
plt.plot(x, y, label='Small Circle', color='green')
plt.plot(px, py, label='Pentagon', color='red')
plt.axis('equal')
plt.legend(loc='upper left')
❷ python2.7绘制五角星
要设置填充色,t.fillcolor("red")
importturtle
t=turtle.Turtle()
t.fillcolor("red")
t.begin_fill()
t.hideturtle()
t.up()
t.goto(-50,-50)
t.left(36)
t.down()
foriinrange(5):
t.forward(200)
t.left(144)
t.end_fill()
❸ 如何用python的turtle画立体五角星
turtle.seth(angle):只改变海龟的行进方向(角度按逆时针),但不行进,angle为绝对度数
❹ python中怎么把五角星画在中间
fromturtleimport*
fillcolor("red")
begin_fill()
whileTrue:
forward(200)
right(144)
ifabs(pos())<1:
break
end_fill()
运行这段代码,会绘制出一个红色五角星图形。
码字不易,望采纳。
❺ python使用turtle库绘制如下的五角星
Turtle库是Python语言中一个很流行的绘制图像的函数库,想象一个小乌龟,在一个横轴为x、纵轴为y的坐标系原点,(0,0)位置开始,它根据一组函数指令的控制,在这个平面坐标系中移动,从而在它爬行的路径上绘制了图形。
❻ 如何用python画一个五角星
#!/usr/bin/env python
import turtle
import time
turtle.forward(100)
turtle.right(144)
time.sleep(1)
turtle.forward(100)
turtle.right(144)
time.sleep(1)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
time.sleep(1)
turtle.right(144)
turtle.forward(100)
time.sleep(3)
❼ python怎么画出一个五角星,要动态效果
fromturtleimportTurtle
t=Turtle();
t.speed(3);
t.pensize(5);
t.color('black','red');
t.begin_fill();
foriinrange(5):
t.forward(200);
t.right(144);
t.end_fill();
❽ 请问如何用Python turtle画一个多角星
一般是要靠算角度的
import turtle
import time
turtle.forward(100)
turtle.right(144)
time.sleep(1)
turtle.forward(100)
turtle.right(144)
time.sleep(1)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
time.sleep(1)
turtle.right(144)
turtle.forward(100)
time.sleep(3)
你可以写一个子函数通过给定的角的数量用公式计算出角度再代入上述代码的角度参数里就OK了
❾ Python中如何画一个画笔颜色为黄色的五角星,边长为200,画布背景颜色为黑色,画
import turtle
turtle.bgcolor("black")
turtle.pencolor("yellow")
turtle.penup()
turtle.goto(-65,65)
turtle.pendown()
for i in range(5):
turtle.left(72)
turtle.fd(200)
turtle.right(144)
turtle.fd(200)
turtle.hideturtle()
❿ 如何采用Python语言绘制一个五角星
#!/usr/bin/env python
import turtle
import time
turtle.forward(100)
turtle.right(144)
time.sleep(1)
turtle.forward(100)
turtle.right(144)
time.sleep(1)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
time.sleep(1)
turtle.right(144)
turtle.forward(100)
time.sleep(3)