IT 140 Pycharm Tutorial 1 Setup and Basics Transcript

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

IT 140 Pycharm Tutorial #1 – Setup and Basics Transcript

[00:00:00.09] Very useful, and will save you a ton of time. Every minute that you watch of this video
tutorial, which probably is not going to be longer than 10 minutes, will save you hours and hours when
coding. So make sure you watch throughout the whole video, and actually understand a lot of the things
that I'm showing here, because I guarantee you, you will thank yourself later for watching this video.

[00:00:20.43] OK. So let's get started with it. I'm going to assume that you guys have no idea how to use
PyCharm. We're going to start directly from the basics. If you're someone who already knows how to
use PyCharm and you know to add configuration and to set up a project, go ahead and skip to the next
video in the series. But if you're not, then follow along.

[00:00:36.33] So if you've already opened up PyCharm you're going to have something that looks like
this. You've probably created a project, or you might have opened an existing project. So what I'm going
to do right now is I'm just going to close this project by going File, Close Project. And now we're going to
be at a window that looks like this. And this is what might be something that it looks like for you if you
haven't done anything yet with PyCharm.

[00:00:56.10] On the left-hand side here, you can have your most recent projects that you can open
really quickly just by clicking on them. And then you can create new projects or open new projects. In
this case, I'm going to open a new project. And a new project is pretty much any folder that contains any
files in it. So, like a text file or a Python file. So I'm just going to go to Desktop, go to Python, YouTube.

[00:01:16.17] And then I already have a project I've set up here. It's called “PyCharm debug.” So you can
see I can open this. I can open the individual file, but I'm just going to open this entire folder, because
this represents a project. OK. So I've done this. And you can see that I have my files on my left-hand side
here.

[00:01:31.68] Now, these files, you can open them in multiple tabs, so you can see I have “debug,” I
have “Dell.” If I want to create a new file in here, then I can right-click, and click New, Python File,
Regular File, which I could add like a text file or something like that. OK. So that's pretty much the basics
of how you open this up.

[00:01:50.64] Now, before I even start writing any code, I want to show you how you would run code. So
let's say you opened up one of your existing Python projects, and you want to run your code. You're
going to notice up here—I'm just going to get rid of this right now so that we can do it fresh—it's going
to say Add Configuration. And this is because you need to add a configuration and a Python interpreter
before you can run all of your files. So what's great about PyCharm is you can add multiple
configurations, and you can run different files by simply selecting the configuration up here.

[00:02:18.28] So let's go up here and click Add Configuration. We're going to click this + icon. We're
going to click Python. And then, we're going to give it a name. So in this case, I want to be running my
“Dell” file, so I'm going to name it “Dell,” so that I know which configuration it is. I need to now select
the script path. I'm going to click this little folder and find my “Dell” file. It should default you to your
project folder. So it should be fast to find. Click OK. And then I need to go to Python Interpreter and
select one.

1
[00:02:44.28] Now, you may or may not already have a Python interpreter. If you don't, don't worry. I'm
going to show that in just one second. But in this case, I have multiple. I'm going to select Python 3.7.
And this is useful as well, as you can run different interpreters on the same project. So now I have that.
And if I wanted to run the file, I could just click this old Run icon.

[00:03:02.70] Now if you don't already have a Python interpreter, it's very easy to set up. All you have to
do is click on File, go to Settings, and then go to Build Execution Development. You're going to go to—
actually, I believe it's here. Sorry. Project, PyCharm Debug. You're going to go to Project Interpreter,
and then you're going to select one up here.

[00:03:21.01] So if you already have Python installed, one of them should show up, like Python 3.7. And
I'm going to do that here. If for some reason, that's not showing up for you, you're going to click on
Settings, click Add, and then you're just going to go to—what you call it—System Interpreter, and then
find the basic Python interpreter and click OK. I'm not going to do that because I already have one set
up. But that's how you add a Python interpreter to your project. OK. So I'm going to apply that. Click OK.
And we're ready to go.

[00:03:49.42] So now I'm going to get into just coding a little bit and showing you some of the things
that PyCharm can help you out with and save you a lot of time. The first thing is autofill. So you can see, I
start typing here, and already, it's showing up what it thinks I want to type. So if I want to do this, I can
simply click Enter, or I can click Tab. So now I'm going to say “import,” and then I want “pygame,” so I'm
going to use the down-arrow key and hit Tab and you can see that it automatically fills up here.

[00:04:14.91] Now notice already, it's giving me some little squiggly lines, and it's greying out my text.
It's just letting me know that I'm not using this import statement. So if I start using it, so I say
“pygame.init”, you can see that now this goes away because it is a used import statement. This already
shows you some of the power of PyCharm. It's extremely, I want to say, intelligent. And it will keep
giving you recommendations. And it knows when you're changing things and doing things wrong.

[00:04:40.46] So you can see I'm getting another error here. A little recommendation that's saying “no
newline at end of file.” So if I click Enter, then you can see it gets rid of that. It's just because it wants a
new line at the end of each file.

[00:04:51.54] OK. So another really cool thing in PyCharm in terms of coding—and this is basic. I've
already shown it in one of my other videos. But I'm just going to create a variable called “x,” and I'm just
going to “print (x)” a bunch of times to the screen here, OK? OK. So this will work fine. It's going to print
“7”—what do you call it—three times.

[00:05:09.03] But what if I want to change this variable name to something like “p?” OK. So if I want to
change this to “p”—now, if I want to change all of these variables here that used to be called “x”—sorry,
because this used to be called “x” and I want to still be printing the same value, seven—I'd have to
change all of these manually, and go “p, p, p,” like that, OK? Now, it's not that bad for only three
instances of the variable. But what if you had this “p” showing up, or the “x” originally, 100 times in your
program? Well, that would take you a long time to change all of those variable names.

[00:05:41.01] So a really cool thing that PyCharm has is—it's called refactoring. So if you highlight your
variable, you right-click on it, you click Refactor, and then Rename, you can change it to whatever you

2
want. So in this case, I'm just going to change it to “test.” I'm going to click Refactor. And you can see
that it changes all of the instances of that variable to the current name.

[00:06:01.10] And this works within a scope, too. So if I do something like “def main():”, and then I just
do “test = 0”, and then, same thing here, I'll “print(test)”, and I decide that I want to now change this,
and I click this, and I click—what do you call it—Refactor, Rename, and then—what do you call it—let's
go like, “hello.” You can see that it now changes it over here. So this did it a bit differently, just because
“test” already exists. But you can see that it's only changing within the scope. It didn't change any of the
“test”s up here like that. OK?

[00:06:34.55] So now let's show some other cool things. So PyCharm has a ton of different commands. If
you go just to View, Navigate Code, and just scroll through them, you can see a ton of things it can do.
Move statement up, move statement down, move line down, move line up. There's tons of different
things. But I'm going to show you a few keyboard shortcuts that should save you a lot of time.

[00:06:53.13] So the first one is just simply Find. Now this one, you can probably guess. It's Ctrl+F. And if
you do this, it brings up a little window here, and you can search for things in your program. Say I want
to find “test,” you can see that it shows me “test” here. And then you can go to the next occurrence of
“test” and keep moving throughout. It's not going to search within the scope. Or actually, it will. But it's
just because it's not a “test” anymore. So if I search for “hello” you can see it shows me this here. And
same thing, we can move down, move up, edit them, change them, and so on.

[00:07:21.48] So another cool keyboard shortcut is to see recent changes that you've done in your file.
Now, you might not find this useful for small files. But if you're working on large files, or with multiple
people, to see the changes is really useful. So if you click Alt+Shift+C, it'll actually pop up all the different
changes that you made. So you can see, I made an external change 29 minutes ago, created Python
script “debug,” deleting, creating Python script “Dell.” And it'll show you all the things you've done in
terms of files and changes to the actual project, which can be useful. Yeah.

[00:07:56.31] OK. So now, another keyboard shortcut. And this one is useful as well, especially if you're
going to be doing the same thing multiple times, or maybe just changing your variable name. And it's
Ctrl+D. You can see, when I press this, it duplicates the line that my cursor is on. So if I go on “hello” and
I click Ctrl+D, you can see now I've duplicated “hello.” And that's really useful as well.

[00:08:15.54] And by the way, all of these things you can do without the keyboard shortcuts. These just
save you a bunch of time. So you can see if I highlight this, I go to Code, now I believe there's something
that says Duplicate Line. It was somewhere. But anyways, there's ways to do it from just looking at the
things up here. So navigate—yeah. Anyways, forget about that. But there's ways that you can do that
without using the keyboard shortcut in case you guys forget.

[00:08:40.12] OK. So another useful thing that PyCharm has is this little to-do list. And this is useful if
you're working on a large project or you're working on something and you're not sure when you're going
to come back to it, and like, you're at the end of a session and you want to remember what to do next.
So if I make a comment just by simply using the pound key here, and then I write “todo,” and then I can
fill this with whatever I want. So I'm going to say “todo finish this function” like this, OK? I'm going to
add another to do up here, and I'm going to say “import other modules”—I need to start this with
“todo.”

3
[00:09:15.65] And you can see whenever I put “todo,” in lowercase, or capitals as well, it's going to turn
this comment into a little green comment here. And you can see that if I'm in the “To Do” tab down
here, it shows two to-do items. So it'll show me exactly where in my file, and what line, where the
comment exists. And then, if I click on it, it'll bring me to it.

[00:09:36.35] So it's not working—so you can see that it scrolled down when I went to “main” to show
me this comment. And this is a good way to remember what you have to do. And it's useful because you
can put these right on where you need to change something, or do something new. Again, you might
not find this useful if you're only using small—what do you call it—small files and small projects, but on
large projects, this is something you really need to keep track of. And it's really useful when you can
comment it directly in the code.

[00:10:04.06] OK, so another one that I want to show you guys—and this one might not seem as
important, but it's kind of a cool selection tool that you can use. And some of you might find it useful. So
I figured I'd show you. So if you hold down the Alt key, and you start selecting something, and then you
move up or down, you can see it selects only the column that you're working in.

[00:10:23.33] So this is holding down the Alt key, and I'm just pressing the left-click on my mouse, and
just scrolling around. You can see it just selects the current column that I'm working with. Again, I don't
know why you would find that useful. But in case any of you have a certain use for it, I figured I'd show it
to you.

[00:10:37.55] OK. So another thing that we can do as well is this thing called “surround with.” So if I type
something like, say, “run = true”, and then I'm just going to type “run”, I'm going to select this, and then
I'm going to hit the keys Ctrl+Alt+T. So Ctrl+Alt+T. And you can see that it pops up this thing called
“surround with”, and I can do “if”, “while”, “try/except”, “try/finally”, “if expr”, “while expr”, “if expr is
none”.

[00:11:04.67] It just automatically creates all of these different things. And if I click, for example, three,
then it automatically will surround my variable with the expression that I selected. And this is useful if
you want to do things quickly, and you remember the key-binds. And if you get used to it, it'll save you a
bunch of time in terms of having to type out all these expressions, and worrying about indentation, and
stuff like that.

[00:11:26.95] Now, there's obviously like a million other commands and things that you can do within
PyCharm and I'm going to cover them in future videos. But I just wanted to show you guys a quick
overview of some of the basic things you can do, and show you the power of PyCharm.

[00:11:39.49] I recommend that you continue watching the rest of the series, because in the next video,
I'm going to go over debugging. And this video, I guarantee you, will save you a ton of time and a ton of
headache when you're working with code and running code, because PyCharm has a really useful and
super powerful debug thing. And I'm going to go through exactly how that works.

[00:11:58.87] Anyways, that's been it for this first video. I'm going to be coming out with a lot more,
showing you more things you can do with PyCharm. This was just a general overview. If you liked the
video, please leave a like and subscribe. And I'll see you again in the next one.

You might also like