python 【旗帜】

 1 import turtle
 2 
 3 def main():
 4     t = turtle.Turtle()
 5     t.hideturtle()
 6     drawFilledRectangle(t,0,0,150,25,"light blue","light blue")
 7     drawFilledRectangle(t,0,25,150,50,"blue","blue")
 8     drawFilledRectangle(t,0,75,150,25,"light blue","light blue")
 9     drawDot(t,75,50,40,"white")
10 
11 def drawFilledRectangle(t,x,y,w,h,colorP="black",colorF="white"):
12     t.pencolor(colorP)
13     t.fillcolor(colorF)
14     t.up()
15     t.goto(x,y)
16     t.down()
17     t.begin_fill()
18     t.goto(x+w,y)
19     t.goto(x+w,y+h)
20     t.goto(x,y+h)
21     t.goto(x,y)
22     t.end_fill()
23 
24 def drawDot(t,x,y,diameter,colorP):
25     t.up()
26     t.goto(x,y)
27     t.pencolor(colorP)
28     t.dot(diameter)
29 
30 main()
 1 import turtle
 2 
 3 def main():
 4     t = turtle.Turtle()
 5     t.hideturtle()
 6     lengthOfSide = 200
 7     drawFivePointStar(t,0,0,lengthOfSide)    
 8 
 9 def drawFivePointStar(t,x,y,lengthOfSide):
10     t.up()
11     t.goto(x,y)
12     t.left(36)
13     t.down()
14     for i in range(5):
15         t.forward(lengthOfSide)
16         t.left(144)
17 
18 main()
 1 import turtle
 2 
 3 heights = [856,420,360,260,205]
 4 
 5 def main():
 6     t = turtle.Turtle()
 7     t.hideturtle()
 8     for i in range(5):
 9         drawFilledRectangle(t,-200+(76*i),0,76,heights[i]/4,"black","light blue")
10     displayText(t)
11 
12 def drawFilledRectangle(t,x,y,w,h,colorP="black",colorF="white"):
13     t.pencolor(colorP)
14     t.fillcolor(colorF)
15     t.up()
16     t.goto(x,y)
17     t.down()
18     t.begin_fill()
19     t.goto(x+w,y)
20     t.goto(x+w,y+h)
21     t.goto(x,y+h)
22     t.goto(x,y)
23     t.end_fill()
24 
25 def displayText(t):
26     languages = ["Mandarin","Spanish","English","Hindi","Bengali"]
27     t.pencolor("blue")
28     t.up()
29     for i in range(5):
30         t.goto(-162+(76*i),heights[i]/4)
31         t.write(str(heights[i]),align='center',font=("Arial",10,"normal"))
32         t.goto(-162+(76*i),10)
33         t.write(languages[i],align='center',font=("Arial",10,"normal"))
34         t.goto(-200,-25)
35         t.write("Principal Languages of the World",font=("Arial",10,"normal"))
36         t.goto(-200,-45)
37         t.write('(in millions of"first language" speakers)',font=("Arial",10,"normal"))
38 
39 main()
柱形图

 

posted @ 2018-03-28 13:03  Justice-V  阅读(265)  评论(0)    收藏  举报