python程式設計 turtle函式庫筆記 4

2021-08-21 11:12:59 字數 1455 閱讀 9149

補充例項:

import

turtle

defmain():

turtle.pensize(3)

turtle.penup()

turtle.goto(

-200,-

50)turtle.pendown()

turtle.begin_fill()

turtle.color(

"red"

)turtle.circle(

40, steps=3

)turtle.end_fill()

turtle.penup()

turtle.goto(

-100,-

50)turtle.pendown()

turtle.begin_fill()

turtle.color(

"blue"

)turtle.circle(

40, steps=4

)turtle.end_fill()

turtle.penup()

turtle.goto(0,

-50)turtle.pendown()

turtle.begin_fill()

turtle.color(

"green"

)turtle.circle(

40, steps=5

)turtle.end_fill()

turtle.penup()

turtle.goto(

100,-50

)turtle.pendown()

turtle.begin_fill()

turtle.color(

"yellow"

)turtle.circle(

40, steps=6

)turtle.end_fill()

turtle.penup()

turtle.goto(

200,-50

)turtle.pendown()

turtle.begin_fill()

turtle.color(

"purple"

)turtle.circle(40)

turtle.end_fill()

turtle.color(

"green"

)turtle.penup()

turtle.goto(

-100,50

)turtle.pendown()

turtle.write((

"cool colorful shapes"

),font =(

"times"

, 18

, "bold"

))turtle.hideturtle()

turtle.done

if__name__ ==

'__main__'

:main()

菜鳥程式設計 python中turtle繪製機器貓

import turtle turtle.speed 15 大臉turtle.setup 800,600 turtle.pendown turtle.colormode 255 turtle.fillcolor 0,128,255 turtle.begin fill turtle.left 44 t...

《Python程式設計快速上手》(三)Python函式

def hello def語句,定義了乙個名為hello 的函式 print howdy 函式體 print howdy 函式體 print hello there 函式體 hello 呼叫 hello 呼叫 hello 呼叫 def hello name name為hello 函式的引數 prin...

python函式式程式設計模式 python函式式程式設計

1 callable內建函式判斷乙個名字是否為乙個可呼叫函式 import math x 1 y math.sqrt callable x false callable y true 2 記錄函式 文件字串 def square x calculates the square of number x...