Python for Beginners, Part 3: The Turtle Module | Hacker Noon


Clever Programmer Hacker Noon profile picture

Clever Programmer

Clever Programmer is a community with over 100,000+ students who are learning to code by building real world projects.

In this part of the Learn Python for Beginners series… We go over how to use the turtle module and learn computer programming in a fun visual way. Things like functions, variables, and more will start to make sense instantly.

See also:


00:00 – Okay, in this video, I wanna talk about00:02the turtle.

00:04 So, “What is the turtle?” You might be asking.

00:06 Well, we’re gonna find out.

00:08 Before we get into some of the more boring

00:11 or the technical stuff, which is actually really fun,

00:13 but before we get into that, I want you

00:15 to be able to visualize the code.

00:17 I want you to be able to see that what we type

00:20 and what we do, you can do something fun with it

00:23 right away, okay?

00:25 And, this is not just something for, maybe,

00:28 kids, this something that’s gonna be very valuable,

00:31 I don’t care how old you are, even if you’re

00:33 two hundred years old because visualization

00:36 is a key tool.

00:37 So if I show you that now, I think it’s gonna benefit

00:40 you in the long run, and also sometimes when you’re

00:42 confused about things, you can try this thing out

00:45 that I’m gonna– about to show you right now,

00:48 to

00:49 maybe make those examples and concepts

00:52 more concrete that you might be a little hazy about.

00:55 Without further ado, let’s get started.

00:57 So, what we are gonna do is start

01:00 doing something with the turtle.

01:02 So, I want you to do “import turtle” as your first line.

01:05 Okay?

01:07 Import, this secret command here,

01:10 what it means is that some programmers

01:13 who stayed up really late at night and wrote code

01:16 and ate Ramen noodle, and that’s all they did, they

01:20 spent hundreds and thousands of hours writing all this

01:22 code for you, and you just get to steal it

01:25 by typing in “import.”

01:27 So basically think of it like you have

01:29 amazing powers at the tip of your fingers

01:31 by using this command “import,” and you

01:33 get all those powers, okay?

01:35 Let’s do

01:37 my turtle is equal to turtle dot turtle.

01:41 Okay?

01:42 And, what we’re gonna do is we’re gonna say

01:44 my turtle dot,

01:49 I don’t know, let’s do something simple

01:51 like move,

01:52 or sorry,

01:53 forward

01:54 100.

01:57 Alright, so let’s see what

02:00 just

02:00 happened.

02:03 Alright, what is going on there, right?

02:05 Let’s close that; let’s start it again.

02:07 So, I’m gonna write this line again,

02:09 and we’re gonna kinda do like a slow motion, okay?

02:11 We’re just gonna play it out again.

02:13 So, I said my turtle,

02:17 right after this first line that I did, right?

02:19 My turtle showed up here, okay?

02:23 Just to make it even clearer for you guys,

02:24 I’m gonna start this thing again, and I’m just gonna write

02:27 the first line that I wrote.

02:28 So, you can see, my turtle showed up, okay?

02:31 Now, let’s say I’m gonna do my turtle dot move,

02:35 or sorry, I keep saying, “move.”0

2:37 Let’s do forward, and let’s do 100, yeah?

02:41 Let’s try it; let’s see what happens.

02:43 Did you just see that thing go to the right?

02:46 So, that thing went to the right.

02:49 Now, what if I wanted to move it up?

02:51 Well, what you need to do is, essentially,

02:54 it’s like…

02:56 Okay, it’s like this.

02:57 I want you to look at my face right now.

02:59 So if I’m the turtle, and I’m going in this direction

03:04 here, I will go like this much,

03:06 and then, in order for me to turn left, what I need

03:09 to do is first turn 90 degrees left,

03:13 like this,

03:14 and then to move forward, I just go forward, right?

03:17 Like

03:19 that.

03:20 Okay?

03:21 So we’re gonna do that with our turtle.

03:23 So let’s do my turtle dot left, how many degrees?

03:28 90 degrees.

03:30 ‘Kay?

03:31 Now, if you notice the turtle, now it’s facing towards

03:34 the left, and it’s looking at going up.

03:36 So we simply

03:38 do

03:39 my turtle

03:40 dot forward

03:41 100 again.

03:43 And you can see my turtle is right over here.

03:48 Now let’s do some more fun stuff.

03:50 Let’s say my turtle dot

03:52 right

03:53 50,

03:56 and let’s say my turtle

04:00 dot forward

04:02 again 100, and you can see we’re starting to make

04:05 interesting shapes now, right?

04:07 Like, what is that?

04:10 Maybe it could be a shirt, it’s a ladder,

04:14 I don’t know.

04:15 I don’t know what that is.

04:17 But, here’s what I want you to do.

04:19 I want you to create a square with the turtle, okay?

04:23 And I want you to copy whatever code that you wrote,

04:26 and I want you to paste it in the comments.

04:28 So, either if you’re watching this on YouTube

04:30 or if you’re watching this on my website,

04:32 on Clever Programmer, I want you to go

04:34 to “Exercise 2: The Turtle” on,

04:38 and I want you to literally copy whatever code

04:42 you have and paste it here, okay?

04:44 I read every single one of your comments,

04:47 and I will go through it, and I will comment on it.

04:49 And other people will get to see what you’re up to as well.

04:52 Okay?

04:53 Also, on my website, I have linked you guys to a blog

04:57 that says “Read this on how to do more fun things

04:59 “with the turtle!”05:01Okay?

05:02 So if you go to this blog, it’ll teach you

05:05 what more fun things you can do, okay?

05:08 So it teaches you how to create stars

05:10 and some really fun shapes, okay?

05:13 So, that is it for this video.

05:16 I will see you in the next video.