How to draw a beautiful and interesting flower with python's little turtle Turtle
This article is about how to use python's little turtle Turtle to draw a beautiful and interesting flower. The editor thinks it is very practical, so I share it with you. I hope you can learn something after reading this article.
In 1967, Daniel G. Bobrow, Wally Feurzeig, Seymour Papert and Cynthia Solomon designed the LOGO programming language to teach children programming in an intuitive way. Although the language can also solve complex problems, what impresses you most is its turtle mapping system (Turtle Graphics).
The turtle module has been built into the Python environment, and you only need to enter 2 lines of statements in Python IDLE to get the baby turtle in place.
Turtleturtle.reset ()
We use turtle to draw an interesting flower.
Import turtle# introduces turtle from the standard library
Def draw_diamond (turt):
For i in range (1pr 3):
Turt.forward (100) # take 100 steps forward
Turt.right (45) # then the turtle turns 45 degrees to the right
Turt.forward (100) # take 100 steps forward
Turt.right (135) # and then turn right by 135o
Def draw_art ():
Window = turtle.Screen () # get a window handle
Window.bgcolor ("blue") # sets the background blue
# create an instance of Turtle
Brad = turtle.Turtle ()
Brad.shape ("turtle") # shape is a sea turtle
Brad.color ("red") # Color is red
Brad.speed ('fast') # the speed of drawing is fast fast slow slow
For i in range (1mem37): # cycle 36 times
Draw_diamond (brad) # draw a diamond as a petal
Brad.right (10) # rotated 10 degrees
Brad.right (90) # A week after painting, the turtle turns 90 degrees
Brad.forward (260) # draw a long line
Window.exitonclick () # the window closes automatically when clicked
Draw_art () # call function
Effect:
(some text source network, only learn to record the use. )
The above is how to use python's little turtle Turtle to draw a beautiful and interesting flower. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.