




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
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的步長 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的步長 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 教科版必修二第三章萬有引力定律同步測試題2024-2025學(xué)年高中畢業(yè)班綜合測試(二)歷史試題含解析
- 四川外國語大學(xué)《普通植物病理學(xué)》2023-2024學(xué)年第二學(xué)期期末試卷
- 重慶經(jīng)貿(mào)職業(yè)學(xué)院《建筑透視》2023-2024學(xué)年第二學(xué)期期末試卷
- 江蘇省南通市崇川區(qū)2025屆六年級(jí)下學(xué)期調(diào)研數(shù)學(xué)試卷含解析
- 某地產(chǎn)項(xiàng)目營銷方案
- 房地產(chǎn)營銷模擬訓(xùn)練
- 堅(jiān)果種植的有機(jī)認(rèn)證流程考核試卷
- 豬的飼養(yǎng)常見疾病識(shí)別考核試卷
- 汽車舊車銷售市場調(diào)研數(shù)據(jù)分析考核試卷
- 電磁兼容測試儀考核試卷
- 跨太平洋伙伴關(guān)系協(xié)議(TPP)
- 流浪動(dòng)物救助中心犬糧公開招投標(biāo)書范本
- 初中數(shù)學(xué)人教九年級(jí)上冊(cè)第二十一章 一元二次方程 解一元二次方程-配方法PPT
- 《氣象災(zāi)害預(yù)警信號(hào)》課件
- 無機(jī)保溫砂漿外墻外保溫系統(tǒng)施工工藝課件
- 高三二輪復(fù)習(xí):產(chǎn)業(yè)轉(zhuǎn)移以富士康的企業(yè)轉(zhuǎn)移為例課件
- 礦井維修電工技能鑒定考試題(高級(jí)工)
- 高中語文《祝福》“誰是兇手”系列之祥林嫂死亡事件《祝福》探究式學(xué)習(xí)(教學(xué)課件) 課件
- 電子商務(wù)稅收法律問題
- 水平泵房水泵聯(lián)合試運(yùn)轉(zhuǎn)方案及安全技術(shù)措施
- 中國政法大學(xué)社會(huì)主義市場經(jīng)濟(jì)概論重點(diǎn)歸納及復(fù)習(xí)試題(楊干忠版)
評(píng)論
0/150
提交評(píng)論