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

熱點內容
phpppt下載 瀏覽:298
1929pdf 瀏覽:364
編譯器是終端嗎 瀏覽:521
pdf改b4 瀏覽:379
命令通道 瀏覽:690
pdf去 瀏覽:543
嵌入式編譯器優化 瀏覽:127
不同品牌安卓一鍵換機用什麼軟體 瀏覽:957
二年下冊運演算法則 瀏覽:137
蘭溪兩級壓縮空壓機 瀏覽:137
網頁如何取回伺服器上的文件 瀏覽:96
linuxphp重啟命令行 瀏覽:575
為什麼我的所有app都登錄不了 瀏覽:558
別樣app海淘怎麼樣 瀏覽:512
聯通app扣費是什麼意思 瀏覽:385
android應用程序管理員許可權 瀏覽:85
石家莊十萬程序員 瀏覽:974
java繼承類實例 瀏覽:289
疫情期間程序員的工資 瀏覽:30
最好的python編譯器 瀏覽:189