In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to use Python to draw the national flag", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to draw the national flag with Python" this article.
Five-star red flag
The five-star red flag is the national flag of the people's Republic of China. It is composed of four small yellow five-pointed stars around a large yellow five-pointed star. The background color is red. The implementation code is as follows:
Turtle.setup (600, 400, 400, 0) 0) turtle.bgcolor ("red") turtle.fillcolor ("yellow") turtle.color ('yellow') turtle.speed (10) # main star turtle.begin_fill () turtle.up () turtle.goto (- 280100) turtle.down () for i in range (5): turtle.forward (150) turtle.right (144C) turtle.end_fill () # deputy star turtle.begin _ fill () turtle.up () turtle.goto (- 100180) turtle.setheading Turtle.down () for i in range (5): turtle.forward (50) turtle.left (144C) turtle.end_fill () turtle.begin_fill () turtle.up () turtle.goto (- 50110) turtle.setheading (30) turtle.down () for i in range (5): turtle.forward (50) turtle.right (144C) turtle.end_fill () turtle.begin_fill () turtle.up () turtle.goto (- 40L50) turtle.setheading ( 5) turtle.down () for i in range (5): turtle.forward (50) turtle.right (144C) turtle.end_fill () turtle.begin_fill () turtle.up () turtle.goto (- 100Ling 10) turtle.setheading (300) turtle.down () for i in range (5): turtle.forward (50) turtle.left (144C) turtle.end_fill () turtle.done () Blue Sky and White Day Flag
The blue sky and white day flag is the national flag of the period of the Republic of China, the flag is blue to show the blue sky, the flag has a cross light in the daytime pattern, the implementation code is as follows:
Def ol (r): na = 15 / 180 * math.pi ol=2*r*math.cos (na) ol=int (round (ol)) return oldef loop (r): t.fd (ol (r)) t.right (150) def main0 (alegue b): t.color (rcred) t.penup () t.goto (- an ol 2) T.goto 2) t.pendown () t.begin_fill () t.goto (- a def main1 2) def main1 () def main1 () def main1 (a 1): t.color ('gray'): Rcblue) t.penup () t.right (90) t.fd (b1amp 2) t.left (90) t.pendown () t.begin_fill () t.fd (A1) t.left (90) t.fd (b1) t.left (90) t.fd (A1) t.left (90) t.fd (b1) t.left (90) t .fd (a _ 1amp 2) t.end_fill () t.penup () t.goto (- a _ max 4 ) t.seth (0) t.pendown () def main2 (r): t.pensize = 20 t.color ('white') 'white') t.penup () t.fd (r) t.right (180-30 / 2) t.pendown () t.begin_fill () for i in range (12): loop (r) t.end_fill () t.penup () t.goto (- a pound 4) t.seth (0) t.pendown () def main3 (R1 Magi R2): t.color (rcblue) Rcblue) t.begin_fill () t.up () t.right (90) t.fd (R1) t.left (90) t.pd () t.circle (R1) t.end_fill () t.penup () t.goto (- a bank 4) t.pendown () t.color ('white' 'white') t.begin_fill () t.pu () t.right (90) t.fd (R2) t.left (90) t.pd () t.circle (R2) t.end_fill () t.penup () t.goto (- a) t.seth (0) t.pendown () def main (a) B): A1 = a / 2 b1 = b / 2 r = A1 / 4 R2 = A1 / 8 R1 = b1 * 17 / 80 main0 (ameme b) main1 (A1 pencil b1) main2 (r) main3 (r1Magne R2) a=1020b=680t.setup (1100Mei 700m 100L 0) Red Cross Flag
The red and white cross is the flag of Switzerland, which is a little different from other countries. The shape of the flag of Switzerland is square, which represents the country's policy of neutrality. The implementation code is as follows:
Def draw_crossshaped (aTurtle, width=0, height=0, color=None): aTurtle = turtle.Turtle () aTurtle.hideturtle () aTurtle.penup () aTurtle.goto (30 50) aTurtle.begin_fill () aTurtle.fillcolor (color) for i in range (4): aTurtle.pendown () aTurtle.fd (width) aTurtle.rt (90) aTurtle.fd (height) aTurtle.rt (90) aTurtle.fd (width) aTurtle.lt (90) aTurtle.end_fill () def draw_RQ (times=20.0): width, height = 26 * times 26 * times window = turtle.Screen () aTurtle = turtle.Turtle () aTurtle.hideturtle () aTurtle.speed (10) aTurtle.penup () aTurtle.goto (- width / 2 Height / 2) aTurtle.pendown () aTurtle.begin_fill () aTurtle.fillcolor ('red') aTurtle.fd (width) aTurtle.right (90) aTurtle.fd (height) aTurtle.right (90) aTurtle.fd (width) aTurtle.right (90) aTurtle.fd (height) aTurtle.right (90) aTurtle.end_fill () draw_crossshaped (aTurtle, width=80, height=80, color='white') window.exitonclick ()
The Stars and Stripes is the flag of the United States, which consists of two parts. On the top left of the flag, there are 50 white stars on the blue background, and the rest are 13 red and white stripes. The implementation code is as follows:
# draw stripes def drawSquar (): turtle.color ('black' 'red') turtle.begin_fill () for i in range (7): turtle.forward (600) turtle.left (90) turtle.forward (90) turtle.left (90) turtle.forward (60) turtle.right (90) turtle.forward (350 / 13) turtle.right (90) turtle.end_fill () # painting Small rectangle def drawSmallsqure (): turtle.color ('blue') turtle.begin_fill () turtle.left (90) turtle.forward (90) turtle.left (90) turtle.forward (300) turtle.left (90) turtle.forward (350 * 7 / 13) turtle.left (90) turtle.forward (300) turtle.end_fill () # draw the star def in the upper left corner DrawSrarts (): X =-10 y = 0 for k in range (4): X =-15 for i in range (6): turtle.goto (x Y) turtle.color ('white') turtle.begin_fill () for j in range (5): turtle.left (144C) turtle.forward (20) x-= 50 turtle.end_fill () y + = 350 / 13 * 2 x =-10 y = 350 / 13 for i in range (3): X =-35 for j in range (5): turtle.goto (x) Y) turtle.color ('white') turtle.begin_fill () for k in range (5): turtle.left (144C) turtle.forward (20) x-= 50 turtle.end_fill () y + = 350 / 13 * 2turtle.setup (0.8,0.8,100) -100) turtle.speed (10) turtle.pu () turtle.forward (300) turtle.left (90) turtle.forward (3502) turtle.left (90) drawSquar () turtle.home () drawSmallsqure () turtle.home () drawSrarts () turtle.hideturtle () turtle.done () above are all the contents of the article "how to draw the National Flag with Python" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.