Python之turtle畫奧運五環 斜眼笑臉

2021-10-19 13:00:56 字數 4226 閱讀 8740

import turtle  # 匯入turtle庫

turtle.width(10)

# 設定畫筆粗細為10

turtle.color(

"blue"

)# 設定畫筆顏色為『藍色·』

turtle.circle(50)

# 畫圓半徑為50

turtle.penup(

)# 抬起畫筆

turtle.goto(

120,0)

# 絕對座標turtle.goto(x,y)

turtle.color(

"black"

)# 設定畫筆顏色為黑色

turtle.pendown(

)# 下筆

turtle.circle(50)

# 畫圓半徑為50

turtle.penup(

)# 抬筆

turtle.goto(

240,0)

# 座標(x,y)

turtle.color(

"red"

)# 畫筆顏色:紅色

turtle.pendown(

)# 下筆

turtle.circle(50)

# 畫圓半徑:50

turtle.penup(

)# 抬筆

turtle.goto(60,

-45)# 座標(x,y)

turtle.color(

"yellow"

)# 顏色:黃色

turtle.pendown(

)# 下筆

turtle.circle(50)

# 畫圓半徑:50

turtle.penup(

)# 抬筆

turtle.goto(

180,-45

)# 座標(x,y)

turtle.color(

"green"

)# 畫筆顏色:綠色

turtle.pendown(

)# 下筆

turtle.circle(50)

# 圓半徑:50

)#畫臉

turtle.begin_fill(

)turtle.circle(

200)

turtle.end_fill(

)turtle.left(90)

#畫嘴turtle.fd(15)

turtle.right(90)

turtle.color(

"yellow"

)turtle.circle(

175,

270)

turtle.color(

"black"

)turtle.circle(

175,

180)

turtle.color(

"yellow"

)turtle.penup(

)turtle.circle(

175,

270)

turtle.pendown(

)turtle.color(

"yellow"

)turtle.goto(

-179

,258

)#左白眼

turtle.color(

"black"

)turtle.fillcolor(

"white"

)turtle.begin_fill(

)turtle.circle(20,

25)turtle.circle(

-170,50

)turtle.circle(13,

175)

turtle.circle(

150,38)

turtle.circle(

280,13)

turtle.end_fill(

)turtle.goto(

-179

,258

)turtle.seth(0)

turtle.color(

"black"

)turtle.begin_fill(

)turtle.circle(16)

turtle.end_fill(

)turtle.color(

"yellow"

)turtle.goto(26,

258)

turtle.color(

"black"

)turtle.fillcolor(

"white"

)#右白眼

turtle.begin_fill(

)turtle.circle(20,

25)turtle.circle(

-170,50

)turtle.circle(13,

175)

turtle.circle(

150,38)

turtle.circle(

280,13)

turtle.end_fill(

)turtle.goto(26,

258)

#右黑眼座標

turtle.seth(0)

turtle.fillcolor(

"black"

)turtle.begin_fill(

)turtle.circle(16)

turtle.end_fill(

)turtle.pencolor(

"black"

)#右眉毛

turtle.penup(

)turtle.goto(60,

338)

#右眉毛尖座標

turtle.pendown(

)turtle.fillcolor(

"black"

)turtle.begin_fill(

)turtle.seth(25)

turtle.circle(-90

,34)turtle.seth(-25

)turtle.circle(

-150,30

)turtle.left(

155)

turtle.circle(80,

55)turtle.circle(60,

80)turtle.end_fill(

)turtle.pencolor(

"black"

)#左眉毛

python之turtle畫蚊香

原理 利用turtle繪製圓形,並使圓半徑逐步增加 如下 import turtle turtle.pensize 30 for i in range 30 turtle.circle i 10,60 turtle.done 下面對 解釋 1 import turtle 匯入turtle庫,turt...

Python用Turtle畫美國國旗

由來 小白學習python 瘋狂的python 快速入門精講 p input 請輸入國旗高度 國旗尺寸 p float p a 1.9 一些重要數值 b 1.0 c 1.9 2 5 d 7 13 e c 12 f d 10 k 0.0616 l 1 13 m 0.37 import turtle a...

使用Python的turtle模組畫國旗

python的turtle模組畫國旗主要用到兩個函式 draw rentangle和draw star。至於函式的呼叫就和我們學的c,c 是一樣的。對於turtle畫國旗的程式中,首先是查詢國旗的畫法,才能用程式實現。自己在實現的過程中主要是對turtle.circle 沒有準確掌握,所以花了一些不...