Python學習 哆啦A夢的腦袋

2021-10-04 18:10:58 字數 4652 閱讀 4911

剛開始畫這個是學校裡學python一開始就學的turtle畫圖,正好作業裡也有要畫乙個**圖,就畫了這個,我一開始是在草稿本子上一點一點的去想他要轉多少度角,然後goto_到哪個位置去畫鼻子眼睛,要正轉還是反轉,還挺麻煩的。

定義乙個goto_()函式,讓goto的時候不會留下痕跡,比較方便

def goto_(x, y):

pu()

goto(x, y)

pd(

##畫頭

def head():

goto_(100, 0)

fillcolor(「blue」)

begin_fill()

lt(45)

circle(150, 270)

lt(45)

fd(15)

lt(135)

circle(-128.78, 270)

lt(135)

fd(15)

end_fill()

fillcolor(「red」)

begin_fill()

circle(-9, 180)

fd(212)

circle(-9, 180)

fd(212)

end_fill()

##畫眼睛

def eye():

fillcolor(「white」)

begin_fill()

goto_(0, 219.82746)

lt(90)

circle(25,180)

fd(25)

circle(25, 180)

fd(25)

goto_(0, 219.82746)

circle(-25, 180)

fd(25)

circle(-25, 180)

fd(25)

end_fill()

pensize(10)

goto_(-10, 194.82746)

circle(10, 180)

goto_(10, 194.82746)

rt(180)

circle(-10,180)

pensize(2)

##畫鼻子和嘴巴

def nose_mouth():

fillcolor(「red」)

begin_fill()

goto_(0, 149.82746)

lt(90)

circle(15)

end_fill()

rt(90)

fd(130)

lt(90)

circle(100, 70)

goto_(0, 19.82746)

rt(250)

circle(-100, 70)

##畫鬍子

def beard():

lt(70)

goto_(-30, 83.79672)

lt(10)

fd(100)

goto_(-30, 83.79672+15.333)

rt(10)

fd(110)

goto_(-30, 83.79672+15.333+15.333)

rt(15)

fd(110)

rt(165)

goto_(30, 83.79672)

rt(10)

fd(100)

goto_(30, 83.79672+15.333)

lt(10)

fd(110)

goto_(30, 83.79672+15.333+15.333)

lt(15)

fd(110)

rt(15)

##畫鈴鐺

def bell():

fillcolor(「gold」)

begin_fill()

goto_(0, -39)

circle(15)

end_fill()

##原始碼

from turtle import

*pensize(2)

defgoto_

(x, y)

: pu(

) goto(x, y)

pd()def

head()

: goto_(

100,0)

fillcolor(

"blue"

) begin_fill(

) lt(45)

circle(

150,

270)

lt(45)

fd(15)

lt(135)

circle(

-128.78

,270

) lt(

135)

fd(15)

end_fill(

) fillcolor(

"red"

) begin_fill(

) circle(-9

,180

) fd(

212)

circle(-9

,180

) fd(

212)

end_fill(

)def

eye():

fillcolor(

"white"

) begin_fill(

) goto_(0,

219.82746

) lt(90)

circle(25,

180)

fd(25)

circle(25,

180)

fd(25)

goto_(0,

219.82746

) circle(-25

,180

) fd(25)

circle(-25

,180

) fd(25)

end_fill(

) pensize(10)

goto_(-10

,194.82746

) circle(10,

180)

goto_(10,

194.82746

) rt(

180)

circle(-10

,180

) pensize(2)

defnose_mouth()

: fillcolor(

"red"

) begin_fill(

) goto_(0,

149.82746

) lt(90)

circle(15)

end_fill(

) rt(90)

fd(130)

lt(90)

circle(

100,70)

goto_(0,

19.82746

) rt(

250)

circle(

-100,70

)def

beard()

: lt(70)

goto_(-30

,83.79672

) lt(10)

fd(100)

goto_(-30

,83.79672

+15.333

) rt(10)

fd(110)

goto_(-30

,83.79672

+15.333

+15.333

) rt(15)

fd(110)

rt(165)

goto_(30,

83.79672

) rt(10)

fd(100)

goto_(30,

83.79672

+15.333

) lt(10)

fd(110)

goto_(30,

83.79672

+15.333

+15.333

) lt(15)

fd(110)

rt(15)

defbell()

: fillcolor(

"gold"

) begin_fill(

) goto_(0,

-39) circle(15)

end_fill(

)def

main()

: head(

) eye(

) nose_mouth(

) beard(

) bell(

) hideturtle(

)if __name__ ==

'__main__'

: main(

) done(

)

哆啦A夢大結局 哆啦大冒險

機器貓最後一集在日本播映.世界,真的不是美麗的 主角大雄突然從睡夢中驚醒,發現自己躺在病床上。原來,世界上從沒有過機器貓 也沒有萬能口袋 也沒有.總之,主角是由於極度的自閉症被送入精神病院的病人,已經在醫院住了八年,靜子是主角兒時暗戀的同伴,主角所有的記憶都停留在八年前的早晨。一切都是主角的幻想.哆...

HHUOJ 1860 哆啦A夢的口袋

題目描述 大家都知道哆啦a夢有乙個神奇的口袋,從那個口袋裡可以變出任何東西。不過最近哆啦a夢的口袋裡資源比較緊張,只能變出某些符合條件的東西。具體條件如下 1 東西的名字僅由字母 大小寫均可 數字組成。僅由字母組成 僅由數字組成或由字母數字共同組成均可。2 如果名字中有數字,則規定連續的數字構成乙個...

openjudge6043 哆啦A夢的時光機

試題描述 哆啦a夢有乙個神奇的道具 時光機。坐著它,大雄和他的夥伴們能穿越時空,回到過去或者去到未來。有一天,大雄和他的夥伴們想穿越時空進行探險,可是時光機卻出了一點故障,只能進行有限的時空穿越操作。大雄他們需要從現在出發,到達乙個目標時間點進行探險,結束後再返回到現在,他們希望盡可能減少時光機的操...