Hello, everyone. And welcome back to enter the python here on Cyber Eri On demand. As always, I'm your instructor, Joe Perry. And today we're starting lesson six python basics. Now, for those of you just jumping in, it may seem strange that lesson six is the python basics.
But I want to thank everyone who's watched with us from less than zero all the way up to now because you have been through a lot of power point and I have great news about that. There's not gonna be a whole lot more
from here on out. We're gonna only use our PowerPoint slides for the objectives and to do or some reason reviews.
The reason for that is because from now on, we're gonna be working right here in this bad boy, which is our a bunch of'em.
We're going to all of our Cody exercises practically. We're gonna talk about how we work in programming. We're gonna talk about Python. We're gonna do it in the V m with actual python code.
We do. Still, however, I don't want anyone to freak out. If you like to read your material, if that's how you learn, that's totally fine. We're gonna have some supplemental materials for all of you Are gonna have some cheat sheets you confined. We have documentation listed. I'm also going to show you where you can find the python documentation and their own on the python manual tutorial.
All sorts of information you can find if you're the kind of person like me who likes to learn by reading gonna have all that available to use. Don't panic
here in Listen. Six
in our V m, we're gonna have four main objectives were gonna split it up into three videos. This first video.
We're gonna discuss the python syntax a little bit, and we're gonna learn to use python on the command lot
in the next video we're actually gonna create. And we're gonna execute our first ever Python program. And then in the final video, we're gonna discuss the python help and dirt functions and help Under or two Really, really useful functions are built into python.
They will touch on some advanced form or advanced material we haven't covered yet. That's totally fine. We're not gonna worry about it too terribly much.
I'm just gonna make you aware that that's the case. and we're gonna use those and we'll show you how to make you
so learning to use python on the command line and learning about python syntax. What we're gonna do is we're gonna go over to our shell, which again all I have right here is Terminator, which is a quality of life upgrade downloaded that I downloaded onto the SVM so that I could use it for the show.
Nothing too terribly fancy or special happening that were here.
Scuse me through the water.
So in our terminal, what we're gonna do is we're gonna just run the python command.
Well, this is gonna do is it's gonna open the python interpreter. However, I want to caution you if you just run Python depending on your implementation, you may get dropped into a python to interpreter.
Which, of course, we've talked about Python too. Needs to be done dying by now. Therefore were only ever going to use python three.
Now, when you use python a lot of times have you run a Python three program in Python two's interpreter. It'll actually work or at least worked for a while because Python three was designed to be backward compatible.
However, there are python, three libraries and python, three modules that do not work in the python to interpreter because they don't exist for Python too.
Therefore, it's important to make sure that you're working in the right interpreter.
So to get to that interpreter, all we're gonna news. First, we're gonna clear our screen. If I can learn to type correctly there, Rio
Clearer screen and we're gonna take Python
three and the number is right next to the word python. There's no space between them that's gonna drop us into the shell. We want
as I mentioned, a couple of as I've already mentioned in this video and I mentioned a few other times I compulsively clear my screen. I like to have a clean workspace. And to do that in the Python interpreter
is control out. Very useful. Command something. No, no.
So we've got our python inter. We've got our Python interpreter open now, and we're ready to start working to do that. I want to talk just a little bit about python syntax. And this is something that will continue to evolve as we discuss it in our if statements and four videos and things like that. They're coming in module two,
where we actually take all of the logic. We spent module one learning and we apply it to Python.
That said, we don't really have time to go over all of that in this video, So I'm going to use an if statement. I'm just gonna trust you not to worry about it too much until it's time to learn how if statements work in Python
that said, it's a useful way to show you syntax. So here we're gonna say, if X equals equals one. Well, first I'm gonna define X. So the pipes under the yell at me
if X equals equals one
Now I said Tab and I hit the tab key. And that's actually so, surprisingly enough, Ah, point of contention for a lot of python programmers. Python in syntax is delineated is delineated by a white space. That is to say,
if I had not entered into entered that tab space here,
if I ran it like this, it wouldn't work. And we can see that by attempting to enter that in our interpreter and is going to tell us it expected an indented block.
So indentation and python is how you differentiate what code belongs to what other, what statements or what functions, or what logical and operations or what have you
when you write an if statement, whatever is going to be executed as a result of that conditional is going to be tabbed in
because it's it's a sub. It's subordinate code to the If ST
Now, the reason I said that tabs are contentious to a lot of python developers is that python is white space delineated, but white space can be achieved with either tabs or spaces.
There are people who will avidly argue for tabs there, people who avidly argue for spaces. And I'm going to make both of those groups upset now and tell you it actually doesn't matter that much. So long as and this is the most important thing.
You're consistent within your own code and with with the paradigm of whatever organization or project you're working on.
I personally believe in using spaces. I like them more, and I think they tend to be more consistent. Tabs are
time with convey Ari from system to system, and from I D. Ito, I'd be eat,
but everyone's gonna have their style. There are a lot of people who will actually go to their tab. Who will implement in their I D that when they hit the tab key, it will instead insert four spaces. When I'm working in the interpreter, I tend just to use tabs just because it's a little bit easier. In my ideas, I often will implement the force faces to attack rule.
Either way, Like I said, the thing that matters is that it is consistent because if you do something like this
tab for the first line prince
and then for the second line
that's actually going to break.
The reason for that is because Python is interpreting the tabs and the spaces as different kinds of white space. So if you were inconsistent, your program will break
either way for now. For this video used tabs, you spaces, whatever works for you. I'm just gonna hit my tab key and keep rolling through.
So the actual if we set out to write so long ago, if X equals equals one
and you can see that nothing printed the reason for that of course is because of the conditional evaluating false. And we'll talk all about how to use if statements and python down the road in a different lesson.
For now, we now understand one how to start the python show to how to run code in the python show. And, of course, three what python white space is supposed to be used for. The last thing we're gonna do in this video is a tradition among programmers were gonna write the phrase we're going to give Python the instruction in print.
Now, this is something you can do along with me Or do right after you watch this video. Hello. World is a traditional way to begin as a programmer. It's just it's the first program that a lot of people wrote. And actually in our next lesson, what we're gonna do is we take this line of code and we're gonna put it into a document and make it into a python script.
So with that,
I'm your instructor, Joe Perry. You've been watching intruder Python here on Sai Berry on demand, and I look forward to having you in our next lesson