資源簡(jiǎn)介
用python繪制出七巧板
代碼片段和文件信息
from?math?import?sqrt
from?turtle?import?*
#?繪制三角形函數(shù)
def?triangle(a?col):
????begin_fill()
????for?i?in?range(1):
????????fd(a)
????????rt(135)
????????fd(a?*?sqrt(2))
????????rt(135)
????????fd(a)
????fillcolor(col)
????end_fill()
????rt(180)
#?繪制正方形函數(shù)
def?square(b?col):
????begin_fill()
????for?i?in?range(4):
????????fd(b)
????????rt(90)
????fillcolor(col)
????end_fill()
????rt(180)
#?繪制菱形函數(shù)
def?diamond(c?col):
????begin_fill()
????for?i?in?range(2):
????????fd(c)
????
- 上一篇:21天學(xué)通Python.源代碼
- 下一篇:python繪制五星紅旗
評(píng)論
共有 條評(píng)論