美文网首页
Udacity_Python程序算例之使用类

Udacity_Python程序算例之使用类

作者: 平平又无奇 | 来源:发表于2017-09-10 17:03 被阅读15次

画乌龟

import turtle
def draw_square(some_turtle):
    for i in range(1,24):
        some_turtle.right(15)
        for j in range(1,5):
            some_turtle.forward(100)
            some_turtle.right(90)
def draw_art():
    window = turtle.Screen()
    window.bgcolor("red")
    
    brad = turtle.Turtle()
    brad.shape("turtle")
    brad.color("yellow")
    brad.speed(2)
    draw_square(brad)
    
    angie = turtle.Turtle()
    angie.shape("arrow")
    angie.color("blue")
    angie.circle(100)
    
    window.exitonclick()
draw_art()
  • 图片输出:
乌龟画图

相关文章

网友评论

      本文标题:Udacity_Python程序算例之使用类

      本文链接:https://www.haomeiwen.com/subject/spzojxtx.html