Python coding 1, the basics
LittleNomster (108)

Hi guys, in this tutorial, I am going to share the basic lines of code for running python turtle and what they do. With this in mind, let’s get started.
So in order to do anything we have to import the program we do this by inputting the following code.
import = turtle
Now it knows we are using python turtle
You see the equal sign there has a different meaning, then when we use math equations. In programming, we use the equal sign to assign something to something. In this case we are assigning turtle to import
Next we need to name our turtle. This is important because it won’t listen without a name. I’m going to call my turtle Jerry
jerry = turtle.Turtle()
This function lets the turtle know what its name is.
Next we need to define a color, you can do this two ways, the first is to say the color name like this.

Import = turtle
jerry = turtleTurtle()
jerry.color(“red”)

The second method is using rgb, like this:

Import = turtle
jerry = turtleTurtle()
jerry.color(“red”)

Next we should define what shape it is, if you want to keep it as an arrow then don’t use this step.

Import = turtle
jerry = turtleTurtle()
jerry.color(“tomato”)
jerry.shape(“turtle”)

The shape I’ve assigned makes it look like a circle. If you want to you can make it another shape, such as a circle, triangle, square, etc.

Now, lets talk about movement, to make the turtle move we need to use the command jerry.forward(10)
The number 10, tells jerry how far to move
If we want to make it go a different direction we can use the two commands,
jerry.left(15)
jerry.right(15)

Now, let’s put some of it together

Import = turtle
jerry = turtleTurtle()
jerry.color(“tomato”)
jerry.shape(“turtle”)
jerry.forward(10)
jerry.left(90)

This code can create lots of different shapes, and is lots of fun!
You can alos use this command to make circles
jerry.circle(25)
the number 25 is the radius
Let’s say you wanted to make an arc. There is a command for that too.
jerry.circle(40,270)
40 is the radius, and 270 is the degrees
You can also fill circles, using the following code block

Import = turtle
jerry = turtleTurtle()
jerry.color(“tomato”)
jerry.shape(“turtle”)
jerry.begin_fill()
jerry.circle(25)
jerry.end_fill

The fill commands show it where to start and where to stop.
You can also change the speed
jerry.speed(2)
The number tells it how fast to go. Just makes sure to put It in before you start moving, otherwise it will not work.
terry.pensize(4)
This command changes the pen size
Alright that is the basics, I’ll make another tutorial on the other code lines later.

You are viewing a single comment. View All
AdriaDonohue (16)

@AdriaDonohue never mind i did not see it was python with turtle OOPS