Ptyhon 无角正方形(熟悉turtle库)

#Python 3.6 (32-bit)

import turtle
turtle.setup(500,500,20,30)
turtle.pensize(20)
turtle.penup()
turtle.fd(-150)
turtle.pendown()
turtle.right(90)
turtle.penup()
turtle.fd(50)
turtle.pendown()
turtle.color("green")
turtle.fd(100)
turtle.penup()
turtle.fd(50)
turtle.pendown()
turtle.color("purple")
turtle.left(90)
turtle.penup()
turtle.fd(50)
turtle.pendown()
turtle.fd(100)
turtle.penup()
turtle.fd(50)
turtle.pendown()
turtle.left(90)
turtle.color("blue")
turtle.penup()
turtle.fd(50)
turtle.pendown()
turtle.fd(100)
turtle.penup()
turtle.fd(50)
turtle.left(90)
turtle.color("red")
turtle.fd(50)
turtle.pendown()
turtle.fd(100)
turtle.penup()
turtle.fd(50)
turtle.hideturtle()

Ptyhon 无角正方形(熟悉turtle库)_第1张图片

PS:本程序仅用作熟悉Pythonturtle库,实际应用请使用循环

你可能感兴趣的:(Python)