導航:首頁 > 編程語言 > python基礎代碼五角星

python基礎代碼五角星

發布時間:2022-11-07 19:01:47

㈠ 怎麼用python畫三角形並填色以及畫五角星並且填色(急!!!)

可以. 用fill='#XXXXXX'參數:

from Tkinter import Tk, Canvas, Frame, BOTH
from math import sin, pi,cos
def pentagramPoints(cx, cy, R):
xita = 36*pi/180
r = R*cos(2*xita)/cos(xita)
points = []
for i in range(0, 10):
angle = i*xita + 0.5*xita
if i % 2:
points+=[cx + r*cos(angle), cy - r*sin(angle)]
else:
points+=[cx + R*cos(angle), cy - R*sin(angle)]
return points
if __name__ == '__main__':
root = Tk()
f = Frame(root)
f.pack(fill=BOTH, expand=1)
canvas = Canvas(f)
canvas.create_polygon(30, 10, 160, 470, 290, 10, outline="#000000", fill="#00ff00", width=3)
canvas.create_polygon(pentagramPoints(480, 240, 100), outline = '#000000', fill='#ff0000', width=3)
canvas.pack(fill=BOTH, expand=1)
root.geometry("640x480+300+300")
root.mainloop()

㈡ python中怎麼把五角星畫在中間

fromturtleimport*
fillcolor("red")
begin_fill()
whileTrue:
forward(200)
right(144)
ifabs(pos())<1:
break
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寫星星符號

foriinrange(1,10):
if(i<=5):
x=i
else:
x=10-i
forjinrange(1,x+1):
print("*",end='')
print(" ")

㈤ 如何用python的turtle畫五角星

turtle.seth(angle):只改變海龜的行進方向(角度按逆時針),但不行進,angle為絕對度數

㈥ 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()

㈦ 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庫是Python語言中一個很流行的繪制圖像的函數庫,想像一個小烏龜,在一個橫軸為x、縱軸為y的坐標系原點,(0,0)位置開始,它根據一組函數指令的控制,在這個平面坐標系中移動,從而在它爬行的路徑上繪制了圖形。

㈨ python五角星

我試了下,這部分參數應該這樣改:

望採納

㈩ 如何採用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基礎代碼五角星相關的資料

熱點內容
四川麻將一般下哪個app 瀏覽:862
反編譯exe腳本 瀏覽:460
源碼文件夾怎麼編譯到固件中 瀏覽:910
ERp列印伺服器錯誤怎麼弄 瀏覽:111
蚌埠u盤加密軟體有哪些 瀏覽:178
前端如何認證伺服器 瀏覽:554
linux切換db2用戶命令 瀏覽:306
相片如何用電解壓 瀏覽:905
碩士程序員去學校當老師 瀏覽:120
pythonstr提取到字典 瀏覽:818
程序員那麼可愛有人看上陸漓了 瀏覽:876
php正則提取圖片 瀏覽:103
pythonlinuxdjango 瀏覽:562
php中文返回亂碼 瀏覽:89
宿舍裝的電信怎麼加密 瀏覽:745
為什麼壓縮文件解壓後變少了 瀏覽:426
現在安卓充電器普遍是什麼型號 瀏覽:714
9日均線36均線主圖指標源碼 瀏覽:349
程序員阿里文化完整版 瀏覽:98
早間新聞在哪個app上面可以看 瀏覽:954