![Python學(xué)習(xí)拓展資料_第1頁](http://file4.renrendoc.com/view/7c8a84045a72d4fa9861782630106bf1/7c8a84045a72d4fa9861782630106bf11.gif)
![Python學(xué)習(xí)拓展資料_第2頁](http://file4.renrendoc.com/view/7c8a84045a72d4fa9861782630106bf1/7c8a84045a72d4fa9861782630106bf12.gif)
![Python學(xué)習(xí)拓展資料_第3頁](http://file4.renrendoc.com/view/7c8a84045a72d4fa9861782630106bf1/7c8a84045a72d4fa9861782630106bf13.gif)
![Python學(xué)習(xí)拓展資料_第4頁](http://file4.renrendoc.com/view/7c8a84045a72d4fa9861782630106bf1/7c8a84045a72d4fa9861782630106bf14.gif)
![Python學(xué)習(xí)拓展資料_第5頁](http://file4.renrendoc.com/view/7c8a84045a72d4fa9861782630106bf1/7c8a84045a72d4fa9861782630106bf15.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、Python turtle:right()、left()、setheading()turtle.right(degree):順時(shí)針移動(dòng)degreeturtle.left(degree):逆時(shí)針移動(dòng)degreesetheading(angle):設(shè)置當(dāng)前朝向?yàn)閍ngle角度for i in range(3):t.right(i*120)t.forward(200)for i in range(3):t.left(i*120)t.forward(200)for i in range(3):t.setheading(i*120)t.forward(200)拓展練習(xí):使用Python畫小豬佩奇from
2、 turtle import * def nose(x,y):#鼻子 penup()#提起筆 goto(x,y)#定位 pendown()#落筆,開始畫 setheading(-30)#將烏龜?shù)姆较蛟O(shè)置為to_angle/為數(shù)字(0-東、90-北、180-西、270-南) begin_fill()#準(zhǔn)備開始填充圖形 a=0.4 for i in range(120): if 0=i30 or 60=i90: a=a+0.08 left(3) #向左轉(zhuǎn)3度 forward(a) #向前走a的步長(zhǎng) else: a=a-0.08 left(3) forward(a) end_fill()#填充完成
3、penup() setheading(90) forward(25) setheading(0) forward(10) pendown() pencolor(255,155,192)#畫筆顏色 setheading(10) begin_fill() circle(5) color(160,82,45)#返回或設(shè)置pencolor和fillcolor end_fill() penup() setheading(0) forward(20) pendown() pencolor(255,155,192) setheading(10) begin_fill() circle(5) color(16
4、0,82,45) end_fill() def head(x,y):#頭 color(255,155,192),pink) penup() goto(x,y) setheading(0) pendown() begin_fill() setheading(180) circle(300,-30) circle(100,-60) circle(80,-100) circle(150,-20) circle(60,-95) setheading(161) circle(-300,15) penup() goto(-100,100) pendown() setheading(-30) a=0.4 f
5、or i in range(60): if 0=i30 or 60=i90: a=a+0.08 lt(3) #向左轉(zhuǎn)3度 fd(a) #向前走a的步長(zhǎng) else: a=a-0.08 lt(3) fd(a) end_fill() def ears(x,y): #耳朵 color(255,155,192),pink) penup() #提起筆移動(dòng) goto(x,y) pendown() begin_fill() setheading(100) #當(dāng)前朝100度方向移動(dòng) circle(-50,50) #半徑50,弧度50 circle(-10,120) circle(-50,54) end_fill
6、() penup() setheading(90) forward(-12) setheading(0) forward(30) pendown() begin_fill() setheading(100) circle(-50,50) circle(-10,120) circle(-50,56) end_fill() def eyes(x,y):#眼睛 color(255,155,192),white) penup() setheading(90) forward(-20) setheading(0) forward(-95) pendown() begin_fill() circle(15
7、) end_fill() color(black) penup() setheading(90) forward(12) setheading(0) forward(-3) pendown() begin_fill() circle(3) end_fill() color(255,155,192),white) penup() seth(90) forward(-25) seth(0) forward(40) pendown() begin_fill() circle(15) end_fill() color(black) penup() setheading(90) forward(12)
8、setheading(0) forward(-3) pendown() begin_fill() circle(3) end_fill() def cheek(x,y):#腮 color(255,155,192) penup() goto(x,y) pendown() setheading(0) begin_fill() circle(30) end_fill() def mouth(x,y): #嘴 color(239,69,19) penup() goto(x,y) pendown() setheading(-80) circle(30,40) circle(40,80) def setting(): #參數(shù)設(shè)置 pensize(4) hideturtle() #使烏龜無形(隱藏) colormode(255) #將其設(shè)置為1.0或255.隨后 顏色三元組的r,g,b值必須在0 . cmode范圍內(nèi) color(255,155,192),pink) setup(840,500) speed(10) def main(): setting() #畫布、畫筆
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 績(jī)效管理培訓(xùn)協(xié)議書(2篇)
- 湖北省宜荊荊隨恩2023-2024學(xué)年高一下學(xué)期3月聯(lián)考物理試卷(解析版)
- 電商行業(yè)的人才培養(yǎng)與教育策略
- 知識(shí)課堂新話題探討為何說正確的按摩對(duì)糖尿病患者的病情有益處
- 中國(guó)機(jī)電設(shè)備安裝工程行業(yè)發(fā)展前景預(yù)測(cè)及投資方向研究報(bào)告
- 丹陽網(wǎng)校操作手冊(cè)
- 2025年液晶樓宇廣告機(jī)項(xiàng)目可行性研究報(bào)告
- 2020-2025年中國(guó)自卸式垃圾車行業(yè)市場(chǎng)調(diào)研分析及投資戰(zhàn)略咨詢報(bào)告
- 電子優(yōu)惠券在電商營(yíng)銷中的運(yùn)用與創(chuàng)新
- 二級(jí)建造師之二建建設(shè)工程法規(guī)及相關(guān)知識(shí)題庫及參考答案【a卷】
- 2025年湘西民族職業(yè)技術(shù)學(xué)院高職單招職業(yè)技能測(cè)試近5年常考版參考題庫含答案解析
- 北京市西城區(qū)2024-2025學(xué)年高三上學(xué)期期末考試語文試題(解析版)
- 《新能源汽車技術(shù)》課件-第二章 動(dòng)力電池
- 拘留所被拘留人員管理教育
- 2025年湖南交通職業(yè)技術(shù)學(xué)院高職單招職業(yè)技能測(cè)試近5年??及鎱⒖碱}庫含答案解析
- 河南省天一大聯(lián)考2024-2025學(xué)年高三上學(xué)期1月期末地理含答案
- 北京市朝陽區(qū)2025下半年事業(yè)單位招聘149人歷年高頻重點(diǎn)提升(共500題)附帶答案詳解
- 2024-2025學(xué)年成都市高一上英語期末考試題(含答案和音頻)
- 三坐標(biāo)考試試題和答案
- 數(shù)字金融 遠(yuǎn)程音視頻手機(jī)銀行技術(shù)規(guī)范
- 《中藥調(diào)劑技術(shù)》課件- 處方調(diào)配
評(píng)論
0/150
提交評(píng)論