如何用python的turtle畫五角星

2021-06-12 16:06:50 字數 5121 閱讀 4043

1樓:匿名使用者

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

如何用python畫一個五角星

2樓:黑板客

首先要學會python,不然有程式也看不明白啊。

然後就是看你要畫什麼樣的了。簡單的5條線就ok。下面的程式就送你一顆星星。雖然沒有天上的那麼亮。:)

from matplotlib import pyplot as plt

import numpy as np

r = 4.0

def circle_p(r,d):

return [r*np.sin(d/180.0*np.pi),r*np.cos(d/180.0*np.pi)]

wjx_p = [circle_p(r,i*72) for i in range(7)]

for i in range(5):

x = [wjx_p[i][0], wjx_p[i+2][0]]

y = [wjx_p[i][1], wjx_p[i+2][1]]

plt.plot(x,y,'r')

plt.show()

想學python可以搜搜我的課程,用python做些事。

如何採用python語言繪製一個五角星

3樓:育知同創教育

#!/usr/bin/env pythonimport 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)

python2.7繪製五角星 10

4樓:職業人和培訓師

要設定填充色,t.fillcolor("red")import turtle

t = turtle.turtle()

t.fillcolor("red")

t.begin_fill()

t.hideturtle()

t.up()

t.goto(-50, -50)

t.left(36)

t.down()

for i in range(5):

t.forward(200)

t.left(144)

t.end_fill()

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

5樓:清山鶴

from turtle import *

fillcolor("red")

begin_fill()

while true:

forward(200)

right(144)

if abs(pos()) < 1:

break

end_fill()

執行這段**,會繪製出一個紅色五角星圖形。

碼字不易,望採納。

6樓:匿名使用者

from tkinter import *

import math

base=tk()

canvas=canvas(base,width=1000,height=800,background='grey')

canvas.pack()

center_x=500

center_y=400

r=200

points=[

center_x-int(r*math.sin(2*math.pi/5)),

center_y-int(r*math.cos(2*math.pi/5)),

center_x+int(r*math.sin(2*math.pi/5)),

center_y-int(r*math.cos(2*math.pi/5)),

center_x-int(r*math.sin(math.pi/5)),

center_y+int(r*math.cos(math.pi/5)),

center_x,

center_y-r,

center_x+int(r*math.sin(math.pi/5)),

center_y+int(r*math.cos(math.pi/5)),

]canvas.create_polygon(points,outline='green',fill='yellow')

base.mainloop()

五角星倒是好畫,win螢幕上難,要使用win32螢幕繪圖吧

python怎麼畫出一個五角星,要動態效果

7樓:匿名使用者

from turtle import turtlet = turtle();

t.speed(3);

t.pensize(5);

t.color('black','red');

t.begin_fill();

for i in range(5):

t.forward(200);

t.right(144);

t.end_fill();

怎麼利用python畫五星紅旗,求**, 5

8樓:大話殘劍

import turtle

t = turtle.turtle()

while true:

t.forward(200)

t.right(144)

if abs(t.pos()) < 1:

break

turtle.done()

上什麼課,最近好像很多人在畫五角星,還要滑鼠點什麼的

如何使用python中的turtle畫一個紅蘋果??

9樓:小菜鳥2無聊寫**

全部**如下列出, 使用的是python3。

可以作為參考,這個**比較簡單,是用圓形來近似地畫一個蘋果。

可以複製**,我把縮排也打進去了,因此我加上了網頁連結,目的地是菜鳥教程(不過與本題無關,[doge])

from turtle import *

def leaf(radius,an=90,co="green",co1="green"):

width(3)

color(co,co1);

pass

begin_fill()

circle(radius/2., an)end_fill()

def stem(radius):

color("")

right(90)

fd(radius)

color("brown")

right(0)

width(9)

circle(radius*5,-19)

color("")

pass

def pulp(radius):

pass#果肉

begin_fill()

circle(radius);

end_fill()

color("white")

left(90)

fd(0.24/0.84*radius)

left(90)

begin_fill()

circle(1.32/0.84*radius);

end_fill()

color("");

home()

fd(radius*5/4/9);

right(90)

fd(radius*2);

right(180);

color("white")

fd(0.16/0.84*radius)

right(-90)

begin_fill()

circle(0.48/0.84*radius);

end_fill()

color("");

fd(0.13/0.37*radius)#0.13right(90)

bk(0.06/0.43*radius)

left(90);

color("")

def main():

speed="fast";

aplfr=160;

reset()

width(3)

#yin(200, "black", "white")#yin(200, "white", "black")ht();

home();

color("")

fd(aplfr/9.);

rt(90);

#fd(aplfr/9)

color("red")

right(90)

strt=pos()

pulp(aplfr*2/2.5)#0.84home()

setpos(strt)

stem(40)

home()

left(180-80);#init as 0st();

pass

leaf(aplfr)

left(90);

leaf(aplfr)

pass

return "done!"

if __name__ == '__main__':

main()

mainloop()

10樓:翰林學庫

turtle庫是python語言中一個很流行的繪製影象的函式庫,想象一個小烏龜,在一個橫軸為x、縱軸為y的座標系原點...

11樓:廢柴白鳳

兄弟找到了麼,求分享一下,我也是異地沒辦法

python問題如何用python求n個數的平均值然後保留小數

l 1,2,3,4,5,4,3,2,1 輸入數字到陣列中 sum l len l 求平均數2.7777777777777777 format sum l len l 求平均數,保留3位小數 2.778 不考慮輸入的最簡單方法 如何在python中保留小數?f lambda x,n round x,n...

如何用python畫出折線圖,python怎麼畫折線圖

用pylab模組的plot函式 pylab.plot x,y 其中x y都是陣列 就能畫出以x,y中元素為座標的折線圖 python怎麼畫折線圖 怎麼用python做光滑折線圖,謝謝了,困擾我很多天了 50 你是想要曲線圖吧,不是這種吧,換個函式吧 參考python散點的平滑曲線化方法 python...

如何用Python寫分散式爬蟲,如何用Python寫一個分散式爬蟲

學習基本的爬蟲抄工作襲原理 基本的http抓取工具,scrapy bloom filter bloom filters by example 如果需bai要大規 du模網頁抓取,你需要學習zhi分散式爬蟲dao 的概念。其實沒那麼玄乎,你只要學會怎樣維護一個所有叢集機器能夠有效分享的分散式佇列就好。...