2 hours 57 minutes
Hello, everyone. And welcome back to intrude a python. You're on Sai Berry on demand. I as always I'm your instructor, Joe Perry. And today we're gonna be in lesson six. This is gonna be our second video of less and six where we're going to create an execute our very first python script. So if you were with us in the last video, you know that we performed a hello world
We printed hello world to the screen
by executing the following line of code
Retyped it real fast.
You think I could do You could have just left it up, but
oh, well, anyway, here's the line of Coby Ran Printed Hello, world. Now what we're gonna do is we're gonna take that line of code we're gonna turn it into a python script.
So first, and probably in a foremost we're gonna go ahead and quit. Are python show
We're gonna clear out of screen.
Now I'm going to be working in them for the rest of these videos. I love them as a text editor. I'm not really I don't generally go in for really big ID's.
It's sort of the same way that you know,
everyone has their own style. But a lot of authors actually prefer to write with typewriters or with old school word processing
tools that don't really have a lot of features on them. It's all about your style and what you know. I learned a program on a very simple basically exactly you see here text on a black screen, so that's what I'm comfortable with. That's what I like, and that's what I'm best at. So we're gonna work in vim
on for those who have never used them or those of you who just downloaded them. A useful piece of information is not really that relevant to this course. Other than that, it will make the rest of your programming a lot easier.
So if you go to, if you use them to edit the MRC file or the same configuration file,
which is going to be found generally speaking, in your etc. Them them. Our seat now, depending on your installation, depending on you know, the system you're on, it might be dot marcie.
In my case, it's just them r c.
So you can open that up and edit it Tight mate.
Super secure password in here
and you can see I've already got it down to the part of the page that is relevant on yours. If you haven't edited this, all of the lines that just disappeared for some reason. Here we go.
There we go.
All of these lines right here. Those are configurations for them. That air probably commented out If you've not edited this s o, just go through and delete the quote. That's a beginning, and that'll enable these. Additionally, I also set auto and Dent, which you can see right here. And all that does is it makes
a CZ. We talked about it on our last video where pilot uses tabs, spaces, What have you
What it does is it takes whatever the indentation of the previous line waas and it takes us back to and it puts that on the new line. When you hit, enter
saves you just a little bit of typing. And it's one of those quality of life upgrades that I really appreciate.
Additionally, I'm going to go ahead and what should not be in visual anymore.
And I'm going to go ahead and find
our dark There it is
and set background equals dark. That just makes it a little bit easier to read on the dark background. So now I am in
wrong command DVD. I'm currently in less than six,
and we're going to create our very first Python script. So we were gonna do that, is gonna run the command of him, and I'm going to use the name H w dot p y. So, Doc P wise the python file extension that tells your shell that tells your operating system this is a python file.
It also tells your editor that this is a pipe on file. If you have syntax highlighting for
Python, so then in our file, all we're gonna do at first is we're gonna write this line
Wrong thing there.
Now, this line is actually not mandatory in Python. It is very useful, however, because it allows you to make your python script execute herbal.
I'll show you the two ways to run a python script here in just a minute. But by doing this, we call that a shebang. That's what these two symbols right here are that the depending on your generation that is either a pound sign. Ah, hash mark a comment Mark hash tag
point is that Mark right there that looks like a tic tac toe game. That and the exclamation mark together that's called a shebang. And that's just an indicator to the limits operating system that this is the This is a python doctor. This is a python script and that it could be run using the python three. Interpreter found in user Been
in the last video we were Hello, World. At the beginning of this video, I showed you how the world again from the command line To do that in a python script, all you have to do is write exactly that command again.
But now, instead of running automatically because you're in an interpreter because you're not in an interpreter rather instead of running automatically,
it's just text. It's just written to the document.
Once we read it, we can quit
how to run this. There are a couple of different possibilities. If we didn't have this your gangland, we could only do it by right by running the command Python three
and then the file name.
In which case band we've printed our first ever Hello world.
tomatoes Command that will set that file to be executed ble with the 777 setting the specific permissions that are basically just all permission.
Hello, world not pi h w not pie.
And you can see here
the color changed on it.
Uh, is now execute herbal
and then you can run it on your Lennox Coman are on your Lennox terminal just by doing dot, slash h w dot p y
dot slash just says, look in the current directory forthis
And there you go. Once again, we have run Hello world So either of those options work Most python programmers will include the line at the top of the file and make it execute a ble.
It's really all about your personal style. It's not mandatory, but it's very commonly used,
and that's all there is to it. In this video, we learned how to write Hello world. We learned how to take the python code that we were doing in the interpreter Put it in a document and run that document. From here on out, we're gonna be able to really do some actual python program. We're gonna spend all of our time in the b m. Very excited for it. Our next video is gonna be the last actual lesson of the last
informative video of module one after. That's just our review.
So tune back in. We're gonna talk about dir help and the python documentation. As always, I'm your instructor, Joe Perry, and thank you for watching intruder python on cyber eri on demand.
Learn to make the most of Python’s object orientation, and set yourself up for advanced ...
2 CEU/CPE Hours Available
Certificate of Completion Offered
Introduction to Programming Using Python
Introduction to Programming Using Python is a practice exam that will test basic programming functions ...