導航:首頁 > 編程語言 > 怎樣用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畫一個五角星相關的資料

熱點內容
dvd光碟存儲漢子演算法 瀏覽:758
蘋果郵件無法連接伺服器地址 瀏覽:963
phpffmpeg轉碼 瀏覽:672
長沙好玩的解壓項目 瀏覽:145
專屬學情分析報告是什麼app 瀏覽:564
php工程部署 瀏覽:833
android全屏透明 瀏覽:737
阿里雲伺服器已開通怎麼辦 瀏覽:803
光遇為什麼登錄時伺服器已滿 瀏覽:302
PDF分析 瀏覽:486
h3c光纖全工半全工設置命令 瀏覽:143
公司法pdf下載 瀏覽:383
linuxmarkdown 瀏覽:350
華為手機怎麼多選文件夾 瀏覽:683
如何取消命令方塊指令 瀏覽:350
風翼app為什麼進不去了 瀏覽:779
im4java壓縮圖片 瀏覽:362
數據查詢網站源碼 瀏覽:151
伊克塞爾文檔怎麼進行加密 瀏覽:893
app轉賬是什麼 瀏覽:163