導航:首頁 > 編程語言 > 怎樣用python畫一個五角星

怎樣用python畫一個五角星

發布時間:2022-12-15 20:36:17

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

閱讀全文

與怎樣用python畫一個五角星相關的資料

熱點內容
架構師需要閱讀的源碼 瀏覽:475
ch編譯器 瀏覽:448
java必須自己寫一個編譯器嗎 瀏覽:936
如何製作androidrom 瀏覽:468
單片機萬能板怎麼寫入程序 瀏覽:18
邁銳寶xl壓縮比 瀏覽:339
靠演算法買彩票 瀏覽:497
程序員考核d 瀏覽:239
自助游中國pdf 瀏覽:746
安卓p40是什麼手機 瀏覽:87
24cxx編程器 瀏覽:591
陰陽師如何查看哪個伺服器有ID 瀏覽:316
公務員照片壓縮 瀏覽:458
編譯的時候怎麼找未定義的函數 瀏覽:352
有什麼我的世界伺服器 瀏覽:306
伺服器亮綠燈是什麼意思 瀏覽:637
python畫的圖如何保存高清版 瀏覽:499
10的搭接還用加密嗎 瀏覽:373
bytedance這個文件夾是什麼意思呢 瀏覽:596
演算法站的客體 瀏覽:84