画饼图 import turtle t = turtle.Pen() for i in range(5): t.penup() t.goto(0, -i*30) t.pendown() t.circle(i*30+30) turtle.done() 画棋盘 import turtle t = turtle.Pen() widthall = 200 width = 20 num = widthall // 20 * 2 + 1 t.speed(10) for r in range(num): t.
1 标准输出 python3利用 print() 来实现标准输出 def print(self, *args, sep=' ', end='\n', file=None): # known special case of print """ print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False) Prints the values to a stream, or to sys.stdout by d
import turtle bob = turtle.Turtle() for i in range(1,5): bob.fd(100) bob.lt(90) turtle.mainloop() import turtle import math def circle(t,r,a): #传入接口arc,在arc中完成大部分计算 arc(t,r,a) def arc(t,r,a): #计算边的长度,同时设定边的个数 length = 2 * math.pi * r * abs(a) / 360 n