Official Turtle Library Tutorial Page
https://docs.python.org/3/contents.html
1. import turtle
• Explanation: This line imports the turtle module, which allows you to use turtle graphics for drawing on a screen. The turtle graphics library is widely used for teaching programming concepts, as it allows you to create shapes and patterns in an easy-to-understand manner.
2. turtle.Screen()
• Explanation: This creates a window (or screen) where the turtle can draw. When this is called, it initializes the screen for the turtle's actions. You can manipulate this screen later if needed (e.g., change the background color, size, etc.).
• Note: It doesn't need to be assigned to a variable because it automatically creates the window.
3. turtle.screensize(200, 150, "coral")
• Explanation: This line contains a small issue with the method name: it should be turtle.screensize() (all lowercase "size"). This method is used to set the size of the drawing area on the screen.
•
o The parameters work as follows:
200: Width of the drawing area in pixels.
150: Height of the drawing area in pixels.
"coral": Sets the background color of the drawing area to a "coral" color.
• Effect: The drawing area will be 200 pixels wide and 150 pixels tall, with a coral-colored background. The actual screen size may be larger, but the drawing area inside the window will be of this size.
4. turtle.dot(10, "Blue")
• Explanation: This command draws a dot at the current position of the turtle.
o 10: The size (diameter) of the dot in pixels.
o "Blue": The color of the dot.
• Effect: A blue dot of 10 pixels in diameter will be drawn at the turtle’s current location.
5. turtle.circle(50)
• Explanation: This command tells the turtle to draw a circle with a radius of 50 pixels. By default, the circle will be drawn in a counterclockwise direction.
• Effect: A circle of radius 50 pixels will be drawn, and the turtle will follow the path of the circle as it draws it.
6. turtle.pencolor("Blue")
• Explanation: This command sets the color of the turtle's pen (the color it uses to draw lines) to "Blue".
• Effect: From this point onward, the turtle will draw using the blue color. This affects any future lines, shapes, or drawings the turtle makes.
7. turtle.circle(-50)
• The radius is -50, which means the circle will be drawn in a clockwise direction instead of the default counterclockwise direction.
___________________________
• Basic colors:
• "red", "green", "blue", "yellow", "black", "white", "gray", "orange", "purple", "pink", "brown", "cyan", "magenta"
• Shades of colors:
• "lightblue", "lightgreen", "lightyellow", "lightgray", "lightpink", "lightcoral", "darkblue", "darkgreen", "darkred"
• Some examples of named colors:
• "violet", "indianred", "aquamarine", "gold", "silver", "beige", "teal", "turquoise"
_______________ CODE_________________
import turtle
turtle.Screen() # Creates the window where turtle will draw.
turtle.screensize(200, 150, "lightgreen") # Set drawing area size to 200x150 pixels, with a background.
turtle.dot(10, "Blue") # Draws a blue dot of 10 pixels in diameter at the turtle's current position.
turtle.circle(50) # Draws a circle with a radius of 50 pixels (counterclockwise).
turtle.pencolor("Red") # Sets the turtle's pen color to blue.
turtle.circle(-50) # Draws a circle with a radius of 50 pixels (clockwise).
Auf dieser Seite können Sie das Online-Video How to Draw Circle in Python Using Turtle Library How To Run Python Code using CMD mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Experts Computer Academy 12 Januar 2025 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 142 Mal angesehen und es wurde von 3 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!