Python, looping exercises

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.