Welcome to your first video on Python.
So in this python series we're going to cover a lot of different topics and we're just going to build
upon them slowly so that everything builds kind of upon the last less it.
So in this first lesson we're gonna be talking about strings and we're going to be working primarily
in Python 3.
So quick thing to note is that my Cally interface might look a little bit different.
I'm on my personal pen test machine here.
The only reason I'm doing that is because when we get into the text editor my text editor on the newer
version of Kelly would not let me edit my preferences very easily so I went ahead and just went back
to my machine that has an older text editor on it so you can follow along completely step by step in
your your Cally and you should be fine.
I just wanted to make sure that the font size is good enough for the recording.
So from here let's go ahead and make a new directory and I'm just gonna call this directory python and
then we're going to change directory into Python and the first thing we're gonna do is we're going to
get it and I'm just going to call this first dot PI.
This will be our first python script and we're gonna build on it.
So the first thing we need to do is declare what it's called a shebang.
So that is a hash bang like this and we're just going to declare bean Python 3 here at the top.
Now what is this do.
This allows us to know or the Linux to know when we run this say we were to run this like Python 3 and
then we just say first stop pi if we run it like this then Python interprets the hash here which you're
going to learn a little bit as a comment.
So all this is commented out we don't worry about it but let's say we wanted to run this a different
We want to say dot forward slash first stop pi then it would actually be interpreted here at the top.
So let's go in here and read this.
It would say hey this I'm going to go ahead and look for bean Python 3.
It's going to find Python 3 in bean because that's where it's stored and then it's going to use that
to execute Python or this python script here.
So we have two ways of running it.
We can either run it Python 3 first at Pi or we can run it as you've seen it with some of our other
scripts with the dot slash like this.
So I always like to declare at the top it's not necessary if you're just going to type in Python 3 but
I always like to do it.
So I'm going to give you some headers here so I'm just going to put a comment in and it's going to say
print strain.
And so the first thing we're going to do is print a string.
Now in the very stereotypical lesson the very first string that most people print is the hello world.
So we're gonna go ahead and just do that.
So let's go ahead and print Hello World and we're going to do that by just typing in print and then
in parentheses with quotation and we're gonna say hello world.
Something like this.
OK and that's it.
So what we can do here is we can just save this and we can go ahead and give this a go.
So what we'll do is we'll say Python 3 and then we can say first in an auto tab out to first stop pi
and you can see now that it wrote out hello world.
So if we go up twice and go back to our g at it we can see here that it ignored printing out anything
here with the comment it didn't interpret this because this is a comment with the hash and we just told
that one instruction which was to print Hello World and it did just that.
So the nice thing about strings is we could use double quotes or we could use single quotes so we could
say sorry hello world like this and we can also use multi line strings so I'm going to tab or hit enter
twice here and we could say something along the lines of print and what if we have a long quote We could
say something like this string runs and then we could say multiple lines like this and we just put that
with triple quotations like this.
And lastly we can do a little bit of what is called concatenation.
We could say something like print this string is and then we'll want to put a space at the end here
and end the quotation that we can put a plus sign in here and we could say something like awesome and
and that parentheses so with all of this you're going to see that OK we can print Hello World.
It should print Hello World hello world.
This string runs multiple lines and this string is awesome and it should be space.
Awesome here because we included the space.
Now you're going to notice even though we've put line breaks in for us no line breaks are going to be
printed.
We'll talk about that here in one second.
So let's save this and let's just run it.
So we're gonna go ahead and run Python 3.
First up Pi.
And everything looks as anticipated right.
So I want to show you one thing.
Let's tab up twice and let's put an ampersand at the end of this.
Watch what this does.
Now we have access not only to our script here but we can also run code as well.
So as long as we save this we can run the code and we don't have to keep exiting out back and forth.
So let's say that we did want to put a line in between these two Hello worlds.
We've got this here what we can do is we can print this can say something like a
and like this like a type today and we close this off and you can put a little note next to it say you
remember and just say new line.
So when you have that backslash n that prints out a new line.
So let's say that and just take a look at that and there you go.
You have a new line put in there so quick and easy way to add a line in a line break.
And.
So here.
Very simple very simple lesson right.
All we're doing is just learning how to print things.
And we're dealing with string so even if you want to go in and build upon this you can add comments
in for yourself to make this easier.
So you can come in here and say double quotes you could say single quotes and then you can come in here
and say triple closed for multiplying.
Right.
And this way you know kind of what everything is doing.
This one you can say here you could say we can also can cat in name.
I don't know if he spelled that correctly but I'm hoping I did.
So that's really it for this lesson.
Just want to cover the basics.
So in the next lesson we're going to start talking about math and the math that python can do and again
where does it continue to build upon this.
So I'll catch you over in the next lesson.