标签:port 显示 库函数 begin pre black one range nbsp
from turtle import * def square(size = 50, rgb = ‘orange‘): pencolor(rgb) for i in range(4): fd(size) left(90) def main(): setup(800, 600) speed(0) for i in range(10): square(80) left(36) hideturtle() done() if __name__ == ‘__main__‘: main()
from turtle import * setup(800, 600) pencolor(‘pink‘) speed(0) for i in range(10): for j in range(2): circle(80, 90) left(90) right(36) hideturtle() done()
from turtle import * setup(800, 600) speed(0) bgcolor(‘black‘) pencolor(‘white‘) angle = 0 size = 2 for i in range(10): for j in range(4): fd(size) angle += 72 seth(angle) size += 5 hideturtle() done()
from turtle import * from random import random def square(size = 50, rgb = ‘orange‘): pencolor(rgb) for i in range(2): fd(size) left(90) fd(size + 25) left(90) def moveto(x = 0, y = 0): penup() goto(x, y) pendown() def main(): z = -500 setup(800, 600) speed(0) for i in range(20): moveto(z, 0) z += 50 rgb = tuple(random() for i in range(3)) color(rgb) begin_fill() square() end_fill() hideturtle() done() if __name__ == ‘__main__‘: main()
实验总结:通过这次实验掌握了turtle的使用方法, 可以使用turtle绘制一些简单的图形,也进一步加强了对函数,循环的理解,练习了引入库函数的方法。
问题:没有找到怎么让图形居中显示的代码方法所以只有取巧达到了视觉效果。
标签:port 显示 库函数 begin pre black one range nbsp
原文地址:https://www.cnblogs.com/pengjinrong/p/14875933.html