Everybody and welcome to the first video where we actually start getting into some code.
Now that we've installed python on the operating system the next thing we need to do is use some sort
of idea or editor for Us to be able to write the code and that just makes it a little bit easier.
Now what I'm going to be using throughout the course is something called Sublime.
Now they have this for Windows and Linux.
And that includes MacOS X so to install that I'll leave a link to the top the top of the video.
However we're not going to go to installing it it's the same processes installing anything else.
However the first thing you want to do is set up a project.
So on this came this time we have a red team nation code just as a folder.
It's completely empty.
There's nothing in there so what you can do is open.
This is sublime.
So we're going to open up a new window on the blind.
You'll see that it's empty now.
Right.
So we go file open.
We're going to head over to the desktop.
Red team nation code to the file we opened and now we have our folder.
So now we can see we have access to this folder with an I.T. first one to create new file and we'll
do file save we'll call this May P Y.
Now the P Y extension is important here because this lets the Python interpreter know that you are working
with a python file and that also lets the OS know that as well.
Main is just this is just go over and name it you can name it whatever you want in this particular case
we're just going to be putting all of our code inside of here it's safe and we're not going to purchase.
So now we've got everything started.
The first thing we're gonna start looking at is the basic structure of a python script.
Now a few ways you can go about this.
I'm going to show you a more uniformed way to do this.
That what I normally do professionally as well.
However note that with python scripts they don't have to be formatted this way.
You can just for example we can just do print Hello and that will work perfectly fine.
However we're gonna have a little bit more of a structure to this.
So the first thing we want to do is we're going to we're not going to I'm not going to go over what
this is particularly so we're going to define Main.
Now again I would go over a little bit more into detail on what each of these are in the next video
but I just want you to understand the process around it.
Now we've got our main so we'll do print
nation
on meat that we're going to do if name sequel to mean then we're going to make actually.
I'll explain this now.
So what's happening here is death is a key word in a line in python.
Now a key word in any language is a special type of term that's used to perform some sort of special
action.
In this case when you're defining a function or a method or a way to hold small bits of code together
and then call it later and have it reused which is what a function is we call it by Def and then we
give it a name.
In our case we're giving it main we could name this technically whatever we want.
We're followed by our braces here now inside of that you can pass parameters.
Now we're going to go over that a little bit more detail we go over how methods work but understand
that these and I call on at the end of the call at the end is required when look when working with methods
python as a language is a is a tab separated or space specific language it's an indented language which
means this right here is is entirely different than this.
So this means it's on the same structure as as main that extra tab means it's inside of me.
So important to understand that.
So when we look here this is a simple if statement this underscore underscore name underscore underscore
is a special variable dedicated to the class or the source file which is what this made up you eye file
is when Python runs that file directly.
So when we go into our command line we do Python Main and DOP Y because we're using.
We're talking to the source file.
It's gonna generate this in memory.
Now it's going to set that to be main as if this is the main file launched.
We're just looking for that to know that we want to call me.
It's just a nice structure way to do this.
We could technically get the same output by just doing that.
However I want to have that structure in place because a little bit more simple to work with what we've
got here is we've got our function defined as main which is tends to be our entry point into the application
then we're printing text onto the screen with the print.
Now these aren't required but in Python 3 you're going to require to have these.
So this just prints whatever text you want inside of the print statement.
Now the print statements built into Python so you don't need to if you're familiar with other languages
you don't need to import or include anything this is just ready to go just from the base language itself.
And this main right here is how you call a function you call it by its name with the brackets.
Not to run this.
We need to make sure that we are in the same boat we are in the same directory so we could see desktop
writing nation code.
Right.
To launch it you would do Python and then the name of the file may not be.
So we you see here we have printed Red Team nation correctly to the screen.
Now if we do the official
and we save that good and rerun it now we have hello world because this is an interpretive language
nothing it needs to be compiled or linked or anything like that that's when we're going be going over
the assembly course next after this.
However just understand that this is an interpretive language and this is how you do a basic print statement
but get familiar with this process here because every snippet of code that we use going forward is going
to keep this same structure just so we can launch Maine on its own without needing it in any other way.