#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: penglaixy
#
# Created: 27/07/2013
# Copyright: (c) penglaixy 2013
# Licence: <your licence>
#-------------------------------------------------------------------------------
import turtle
__import__("turtle").__tracealbe__=False
import time
__import__("time").__tracealbe__=False
def main():
def make_window(colr, ttle):
'''
set up the window with the given background color and title
'''
w = turtle.Screen()
w.bgcolor(colr)
w.title(ttle)
return w
def make_turtle(colr, sz):
'''
set up a turtle with the given color and pensize
'''
t = turtle.Turtle()
t.color(colr)
t.pensize(sz)
return t
def draw_square(t, sz):
''' Make turtle t draw a square of sz'''
for i in range(4):
t.forward(sz)
t.left(90)
wn = make_window('lightgreen','''yuxiangyang's testing''')
alex = make_turtle('navy blue', 5)
for j in range(5):
draw_square(alex, 20)
alex.penup()
alex.forward(40)
alex.pendown()
time.sleep(8)
wn.bye()
if __name__ == '__main__':
main()
How to think like a computer scientist: 第四章 课后习题 1
最新推荐文章于 2021-10-03 12:08:29 发布