We will discuss the difference between an interactive python terminal vs. A python script.
In case you missed it, here are the previous parts of the series:
00:00 - Okay, in this video,
00:01I'm gonna go over the solution to the previous problem
00:03 that I posed to you, and also,
00:05 we're gonna learn how to write the turtle,
00:07 the entire thing,
00:09 in one go.
00:11 So, the problem that I posed to you is,
00:14 make a square with the turtle.
00:16 Well, in your case,
00:17 let's see how you could do exactly that.
00:21 So, let me find the file where we opened up the turtle.
00:23 Let me close that guy right there.
00:25 Copy this line and paste it right there.
00:29 Okay, my turtle has begun.
00:31 Well, the idea is simple.
00:34 I take this line forward, and go 100.
00:38 Now, since sometimes programmers are lazy,
00:40 I don't want to keep writing this over and over again,
00:42 so one thing I can do to make my life easier
00:45 is go to the line that I want to click on,
00:48 I want to use, basically.
00:50 Go to that line, click my mouse there,
00:52 hit 'enter', it brings that down at the bottom,
00:55 as you can see right here.
00:56 And now I can just hit 'enter'.
00:59 So, you can see my turtle just moved left, okay?
01:02 Now it's facing up.
01:05 Now what I want to do is move it forward again,
01:08 and you can see that it's facing up again,
01:11 er, I'm sorry, it's ...
01:13 It moved up, now I need to make it face left.
01:16 So, how do I do that?
01:17 I go left, make it turn 90 degrees,
01:19 and you can see it turned 90 degrees.
01:22 Now I want it to move 100 again.
01:25 You can see it move forward.
01:27 And 90 degrees, and then 100 once again,
01:31 and I have made the square.
01:34 Now, what I want you to be able to do is,
01:38 make a Python file, which means that,
01:41 remember this thing that we opened up right here,
01:45 where we write all of the code at once?
01:48 So, for example,
01:50 I'm gonna close it,
01:51 I'm gonna show you how to open it again, okay?
01:53 So, I'm gonna close this one,
01:54 and I will simply open it again.
01:56 'New file', or 'Command-N'.
01:59 And I will go and put it to the right side,
02:02 just so I have these side by side,
02:05 and I will say something like 'import turtle'.
02:08 Remember that command.
02:09 If you don't use that command
02:11and you try to do 'turtle',
02:12 your program will be like,
02:14 "What the heck is 'turtle'?"
02:16 So, by doing 'import turtle',
02:18 now it knows what 'turtle' is.
02:20 It's like when you're talking about your friends,
02:24 if you talk about your friend John, right?
02:27 Like, let's say you're talking about your friend John
02:29 to your mom, or to your dad,
02:32 and you're like,
02:33 "Dad, this guy blah blah blah",
02:35 you're dad's gonna be like,
02:36 "Who the heck is John?"
02:37 So, you're gonna be like,
02:38 "Oh, yeah, you remember John from my fifth grade class?"
02:43 And then your dad, if you're talking to him,
02:44 he's gonna say,
02:45 "Oh, okay, I know who you're talking about".
02:47 So, 'import' is basically like,
02:50 hey, Python,
02:51 import that turtle that those coders wrote,
02:54 and now we can use it,
02:55 and Python is like,
02:56 "Oh, that turtle",
02:58 but if you don't have this 'import' command here,
03:01Python's gonna be like,
03:02 "What the heck?
03:03 "What turtle are you talking about?
03:04 "You must be out of your mind."
03:06 Anyways.
03:07 We're gonna import this turtle.
03:09 Alright, so now here's what I want you to do.
03:11 I want you to write a script that makes the turtle
03:14 in one single go, okay?
03:18 And I want you to make that square with the turtle
03:21 straight up in one go.
03:22 For example,
03:23 let's come over here to our script that I've written,
03:26 and if I write stuff here,
03:28 it does things immediately, right?
03:30 As you saw,
03:30 but if I come to my right side over here ...
03:34 Oh, by the way, just one quick note.
03:36 Whatever you do, do not name this file 'turtle.py'.
03:40 You can name it 'turtle_game', or 'game',
03:44 or something else,
03:45 just don't name it turtle,
03:47 because then it confuses this turtle here
03:49 with this file,
03:50 and everything goes all over the place.
03:53 So, don't do that,
03:54 'cause I ended up doing that and it caused lots of problems.
03:58 Alright, so let me just show you what happens
04:00 when I run this file.
04:02 I'll go to 'Run', I'll hit 'Run module',
04:04 and hit 'OK'.
04:06 And you can see that my turtle went
04:08 and did all those things in one go.
04:10 How cool is that?
04:11 So you don't have to sit there, type it all in.
04:13 You can just write it in one go,
04:14 and it'll do that every single time.
04:17 So, I want you to work on that square,
04:19 but before you go and do that,
04:21I just want to show you what this file actually looks like.
04:24 So, if I go to,
04:29 let's say,
04:30 'Documents', and 'Clever Programmer',
04:33 'Practice Exercises',
04:35 and we take a look at this file, 'turtle_game',
04:38 it's just a text file with this code in here, okay?
04:42 That's really it, that's all that's going on in here.
04:45 So, I'm gonna
04:47 leave it here.
04:50 The code that you write for the square,
04:52 I want you to either go to the Youtube place,
04:55 Youtube channel, and post it in the comments,
04:58 or I want you to paste your code right here in the comments
05:01on cleverprogrammer.com, okay?
05:03 I'm gonna take a look at it.
05:05 I will see you in the next video.