Python Turtle Star

Python Turtle Star Python Turtle Star Below are some simple turtle commands that are important and used to create graphics using the turtle module in Python:

Code to draw Python Turtle Star

# importing turtle
import turtle

# Set up the screen
window = turtle.Screen()

# Create a turtle object
star = turtle.Turtle()
star.shape("turtle")

# setting color, size and position of pen
star.pencolor("Red")
star.pensize(10)
star.goto(-100, 0)

# create a star pattern
for i in range(5):
    star.forward(220)
    star.right(144)

# to stop output screen
turtle.done()

Output:

output for Python Turtle Star

Important Python turtle Commands

Below are some simple turtle commands that are important and used to create graphics using the turtle module in Python:

  • forward():  With help of forward command we can move the turtle in a straight direction by a certain number of units.
  • backward(): This command is the same as a forward command in this case it will move the turtle backward by a certain number of units. 
  • right(): To move turtle in right direction right() command is used. This command turns the turtle right by a certain number of degrees. You can specify the number of degrees as an argument
  • left(): To take a left turn we will use the left() command. This command turns the turtle left by a certain number of degrees.
  • penup(): This command lifts the turtle’s pen off the digital canvas, so it doesn’t draw anything on the screen. This command is used to pick up the pen and then move to the new location to draw other things, if you move the turtle in the penup state it won’t draw anything. This is useful for shifting the turtle.
  • pendown(): By default, turtle operates with pendown state, but if you use the penup() command, it will stop drawing. To resume drawing, you will need to use the pendown() command to return to the previous drawing state.
  • pencolor():  To make the drawing more visually appealing we use pencolor() commands to change the color of the link of the turtle drawing.
  • shape(): When you will run the program then there will be a shape representing your drawing cursor, which is managed by shape().
  • pensize(): To manage the thickness of the pen
  • goto(): To take the turtle to a specific position, coordinates-> (x, y)

    Thank you for visiting our website.


    Also Read:

    Share:

    Author: Harry

    Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at admin@violet-cat-415996.hostingersite.com Thank you