实验8 python库应用编程与体验
作者:互联网
task3.py
1 from turtle import * 2 3 def square(size=50, rgb='orange'): 4 pencolor(rgb) 5 for i in range(4): 6 fd(size) 7 left(90) 8 9 10 def main(): 11 setup(800, 600) 12 speed(0) 13 14 n = 10 15 for i in range(n): 16 square(80) 17 left(360/n) 18 19 hideturtle() 20 done() 21 22 23 if __name__ == '__main__': 24 main()
task4.py
1 from turtle import * 2 3 setup(800, 600) 4 pencolor('pink') 5 6 n = 10 7 for i in range(n): 8 for j in range(2): 9 circle(80, 90) 10 left(90) 11 12 right(360/n) 13 14 hideturtle() 15 done()
task5.py
1 from turtle import * 2 3 setup(800, 600) 4 bgcolor('black') 5 pencolor('white') 6 speed(0) 7 8 angle = 0 9 size = 2 10 11 n = 20 12 for i in range(n): 13 for j in range(4): 14 fd(size) 15 angle += 72 16 seth(angle) 17 size += 5 18 19 hideturtle() 20 done()
实验总结:用python画图还是挺奇妙的(ps:最后一个图我看起来有点晕),不过有时候也有点转不过来弯,借鉴了一下大佬们的代码,膜拜大佬!
标签:__,10,600,python,编程,range,体验,turtle,size 来源: https://www.cnblogs.com/yan-starry0708/p/16372349.html