❶ 如何用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)