From turtle import *fillcolor ("Red") Begin_fill () for I in range (5): Up () Goto (0,-20*i) down () Circle ( 20*i) End_fill ()
First, Concentric circle
Second, the sun flower
From turtle import *color (' Red ', ' yellow ') the Begin_fill () while True: forward (+) right (in) if ABS (POS ( )) <1: Breakend_fill () Done ()
Third, flag
From turtle Import *setup (640,440,0,0) color ("yellow") bgcolor ("Red") FillColor ("Yellow") def llf_goto (x, y): Up () goto (x, y) down () def Llf_draw (r): Begin_fill () for I in range (5): forward (R) Right (144) End_fill () Llf_goto ( -286,132) Llf_draw ( -132,180) Llf_goto ( -88,132) Llf_draw Draw (Llf_goto) ( -88,72) Llf_draw (+) Llf_goto ( -132,22) Llf_draw (50)
Four, draw diamond Flower
Import Turtledef draw_1 (LLF): Llf.forward (+) llf.right (GB) Llf.forward (+ ) Llf.right (135) def Draw_2 (): window=turtle. Screen () Window.bgcolor ("Blue") llf=turtle. Turtle () llf.shape ("Turtle") Llf.color ("orange") llf.speed ("fastest") for I in range (1,37): draw_1 (LLF) draw_1 (LLF) llf.left (llf.right llf.forward) 155 ( ' Green ') Llf.forward (145) Window.exitonclick () draw_2 ()
Python, looping exercises