Python123: Python基本图形绘制 (第2周)

1、实例2: Python蟒蛇绘制

import turtle
turtle.setup(650,350,200,200)
turtle.penup()
turtle.fd(-250)
turtle.pendown()
turtle.pensize(25)
turtle.pencolor(“purple”)
turtle.seth(-40)
for i in range(4):
turtle.circle(40,80)
turtle.circle(-40,80)
turtle.circle(40,80/2)
turtle.fd(40)
turtle.circle(16,180)
turtle.fd(40*2/3)
turtle.done()

2、turtle正方形绘制

import turtle
turtle.setup(650,450,400,400)
turtle.penup()
turtle.goto(-150,150)
turtle.pendown()
turtle.pensize(5)
turtle.fd(200)
for i in range(3):
turtle.right(90)
turtle.fd(200)

3、turtle六边形绘制

import turtle
turtle.setup(650,450,400,400)
turtle.penup()
turtle.goto(-100,100)
turtle.pendown()
turtle.pensize(5)
turtle.fd(100)
for i in range(5):
turtle.right(60)
turtle.fd(100)

4、turtle叠边形绘制

import turtle
turtle.setup(650,450,400,400)
turtle.penup()
turtle.goto(-100,100)
turtle.pendown()
turtle.pensize(5)
turtle.fd(100)
for i in range(8):
turtle.right(80)
turtle.fd(100)

你可能感兴趣的:(Python基础)