条件,循环,函数定义,练习
1太阳花
from turtle import*
color('yellow','yellow')
begin_fill()
while True:
forward(100)
left(170)
if(abs(pos()))<1:
break
end_fill()
done()
2同心圆
from turtle import*
for i in range(5):
up()
goto(0,-20*(1+i))
down()
circle(20*(i+1))
write(10-i)
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAT4AAAEACAIAAAClKo26AAAWLklEQVR4Ae2dPZYVORKFq+bMUqANDiuAFcA4WLh4YNILaHO8ccAEr10snIYV0CvgYHTVXmrilShVkn9PPzekCOV9BmQqpavQjfiesh71ksubm5sLvugAHfDmwL+8Bcx46QAdODlAdFkHdMClA0TXZdoYNB0guqwBOuDSAaLrMm0Mmg4QXdYAHXDpANF1mTYGTQeILmuADrh0gOi6TBuDpgNElzVAB1w6QHRdpo1B0wGiyxqgAy4dILou08ag6QDRZQ3QAZcOEF2XaWPQdIDosgbogEsHiK7LtDFoOkB0WQN0wKUDRNdl2hg0HSC6rAE64NIBousybQyaDhBd1gAdcOkA0XWZNgZNB4gua4AOuHSA6LpMG4OmA0SXNUAHXDpAdF2mjUHTAaLLGqADLh0gui7TxqDpANFlDdABlw4QXZdpY9B0gOiyBuiASweIrsu0MWg6QHRZA3TApQP/dhn1wYK+vLxcrvjm5mbZyJbjOEB0DeV6FVGJb5XSrM6GFslQQA5crpYFSJwymw6sggfJhZ7y5mJ4oYcDRLeR6zOiIJSmh9539vQ42TPdAaKb7lVJz8hMY1b3Y7UZ1X7MvDpzgOjODMGcemHDS5yYrIylQnSR+fRLgt/IkflzpUV0Aekaqe5HWgsgtYYliG55csau8rFXV551MyOJbnYqjlbTR1tvdkF0GkB0M4wPRWzqs+KM6Ku7Hnz51f6BBYhukqGs2mgTrYhW9D0guuf9l2I97E675Q492XKmWTuLcs9q7jA77tCcHXMaXCK66yazLtd9WbTSqIUljRqI7orRUo68Q17xZbuJjm17o3WFNfqLs9xDfrEj54TW5bgF6Et0703k1nHvRekRPSx1Lnsc0T1Zxh0ju3C2B9DMbW+Q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1Ic4C/w5zmE3vRAWMOEF1jCWE4dCDNAaKb5hN70QFjDhBdYwlhOHQgzQGim+YTe9EBYw4QXWMJYTh0IM0BopvmE3vRAWMOEF1jCWE4dCDNAaKb5hN70QFjDhBdYwlhOHQgzQGim+YTe9EBYw4QXWMJYTh0IM0BopvmE3vRAWMOEF1jCWE4dCDNgf8D202ZkwA2pj8AAAAASUVORK5CYIIA)
3国旗
import turtle
turtle.color('yellow')
turtle.bgcolor('red')
turtle.fillcolor('yellow')
turtle.speed(50)
def mygoto(x,y):
turtle.up()
turtle.goto(x,y)
turtle.down()
turtle.begin_fill()
mygoto(-230,100)
for i in range(5):
turtle.forward(200)
turtle.left(144)
turtle.end_fill()
turtle.begin_fill()
mygoto(-70,250)
for i in range(5):
turtle.forward(50)
turtle.left(144)
turtle.end_fill()
turtle.begin_fill()
mygoto(0,150)
for i in range(5):
turtle.forward(50)
turtle.left(144)
turtle.end_fill()
turtle.begin_fill()
mygoto(-70,-50)
for i in range(5):
turtle.forward(50)
turtle.left(144)
turtle.end_fill()
turtle.begin_fill()
mygoto(0,50)
for i in range(5):
turtle.forward(50)
turtle.left(144)
turtle.end_fill()
4,五角星
import turtle
for i in range(5):
turtle.forward(200)
turtle.left(144)
效果图: