条件循环函数定义 练习
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了条件循环函数定义 练习相关的知识,希望对你有一定的参考价值。
- 画五角星
-
import turtle for i in range(5): turtle.forward(200) turtle.right(144)
- 画同心圆
-
import turtle for i in range(5): turtle.circle(20*(1+i)) turtle.up() turtle.goto(0,-20*(1+i)) turtle.down()
turtle.done() - 画太阳花
-
import turtle
from turtle import *
turtle.color(\'red\',\'yellow\')
turtle.begin_fill()
while True:
turtle.speed(10)
turtle.forward(200)
turtle.left(170)
if (abs(pos()))<1:
break
turtle.end_fill()
turtle.done() - 画五个五角星
-
import turtle turtle.fillcolor(\'red\') turtle.speed(10) def my_goto(x,y): turtle.up() turtle.goto(x,y) turtle.down() def my_cd(s): turtle.forward(s) turtle.left(90) def my_draw5(r): turtle.begin_fill() for i in range(5): turtle.forward(r) turtle.right(144) turtle.end_fill() #国旗红底 turtle.begin_fill() my_goto(-270,-180) my_cd(550) my_cd(330) my_cd(550) my_cd(330) turtle.end_fill() turtle.fillcolor(\'yellow\') turtle.color(\'yellow\') my_goto(-195,99) my_draw5(90) turtle.left(30) my_goto(-75,130) my_draw5(30) my_goto(-45,100) my_draw5(30) turtle.right(30) my_goto(-45,60) my_draw5(30) turtle.right(20) my_goto(-75,21) my_draw5(30) turtle.done()
- 画◇花瓣的太阳花
-
import turtle turtle.speed(10) turtle.bgcolor(\'blue\') turtle.fillcolor(\'red\') def my_draw(s): turtle.begin_fill() turtle.forward(s) turtle.right(45) turtle.forward(100) turtle.right(135) turtle.forward(s) turtle.right(45) turtle.forward(100) turtle.right(135) turtle.end_fill() for i in range(1,37): my_draw(100) turtle.left(10) turtle.right(90) turtle.forward(300) turtle.done()
以上是关于条件循环函数定义 练习的主要内容,如果未能解决你的问题,请参考以下文章