Python is a very popular
programming language. In fact, it's the most recommended programming
language for absolute beginners to start with. However, there are a lot of people who don't
really understand the journey of learning Python. What is the learning path? What steps or levels they have to
take or go through in order to master the Python programming
language in this video, I'm going to talk about the six levels
or the six steps that will take you from being an absolute beginner in
Python to being a master in Python. So let's jump right into it. The first level is what I call
level zero level zero is if you are either an absolute beginner
to programming in general, or if you are coming to Python from
a different programming language, the only difference is the time. It will take you to learn
the concepts at this level. What are the concepts that
we're talking about here? So the concepts we're talking about here
are not concepts that are exclusive to Python at this level. Since you are
just beginning your programming journey, you will be learning concepts, fundamental programming concepts
that are not just specific to Python, but you can use the same concepts and
you will find the same concepts in any other programming language that
you will be learning in the future. What are these concepts,
for example, variables, what variables are and how
to use variables, functions, how to use functions in your programs, the different operations that you can
perform in your data. For example, how to do arithmetic operations, like
addition, multiplication, subtraction, or how you can do comparison operations
greater than less than equality operators, or even logical operators
and or all of that fun stuff. And in addition to the
operations, also the types, the different data types that
your programming language
supports, for example, integers, floating point
numbers, strings, lists, all of these different data types
are also things that are not just specific to Python, but you will see the same concepts in
other programming languages as well. So what I really want you to focus
when you are at this level is don't get bogged down by the Python specifics, but try to understand the fundamental
programming concepts themselves, because it will help you. If you want to learn any other
programming language in the future. In this level, you're also going to be learning about
loops like for loops and while loops. And these are statements that you can
use if you want to repeat the same block of code over and over again. And you
will also be learning about conditionals, like if statements and this will allow
you to write programs that will behave differently based on a specific condition. So all of these concepts, like
I said, are very important. They are fundamental and you will see
them in any other programming language you will ever learn when you combine
all of these concepts together. This is when you can actually
start writing code that is useful. That is doing something useful, the best way to learn level
zero and to master levels, zero is to write a lot of code. And there are a lot of problems out
there that you can actually solve after mastering the concepts of level zero. So make sure to write a lot of code and
make sure you really master this level very, very well. And you really internalize
and understand these concepts because they're really fundamental
level one object oriented programming in Python, object oriented programming
is a programming paradigm. It's a programming model.
It's a way of thinking, looking into a problem and then trying
to structure the solution of a problem using what we call objects. Like I said, by finishing level zero, you are very
qualified to actually start writing code, but the code that you will probably
be writing at this level level zero is most likely to be procedural code. Procedural code is also
a programming paradigm. It's a way of thinking where you look
to a problem and then you solve the problem by having a bunch of
functions that solve smaller problems. And then you solve the bigger problem
by solving these smaller problems. This is basically how most of us
start learning any programming language. We start by, writing solutions, writing code in a procedural way. The next step in the journey is
to learn about object oriented programming. It's a different way of thinking
about the problem and structuring your solution, but it is very important
for two reasons, reason. Number one, most of the widely used
programming languages. These days are object oriented
programming languages. If we talk about C plus
plus, or Java or Python, all of these three programming languages, they're very widely used in industry
and all of them are object oriented, programming languages. Number two, the object oriented programming
paradigm is actually very simple to understand, and it helps you write
readable very efficient code. And again, it's very
widely used in industry. So you really need to master
this programming paradigm. If you want to be a good
software engineer in general, and similar to level zero, the object oriented
concepts are fundamental concepts that are not specific
to Python. So for example, concepts like inheritance
polymorphism composition, all of these concepts are concepts
that you will find in all of the programming languages that support
object oriented programming. So again, what you're learning here is
not going to be specific to, but you can use it the same concepts
and the same knowledge when you go from learning Python to learning,
say Java or C plus plus. So this is very important. So again, I would focus 100% on really
understanding the company before you try to learn
how to apply these concepts in Python. Okay. Once you understand
these fundamental concepts, you can then see, okay, how
can I create a Class in Python? How can I create an object in Python? How can I inherit from another object? Or how can I override it? Wait a method. So to summarize the best way to learn
object oriented programming in Python is number one, start with learning the object
oriented concepts in an abstract way. Don't think about Python for now.
Try to understand what a class is, what an object is, what the
concept of inheritance means, what the concept of encapsulation,
polymorphism, and so on and so forth. After you master these concepts, the second step is to make sure
you understand how to apply these concepts to Python. So
how to create classes inPython, how to create objects in
Python, how to say, Oh, I want this class to inherit from this
other class, how to override methods. Okay. And then the last step is again, solve a lot of problems. So you can even go back to the same
problems that you solved in level zero, and see if you can solve the same problems
using object oriented programming. So again, this step, the best way to learn is
to write a bunch of code. Now let's talk about level two
socket programming in Python. So far what we've been doing. We've been writing code
that runs on our machine, which means you have a laptop. You write code on your laptop and
this code just runs on your machine. You have not written any code
that interacts with other code that is written in a
different machine. For example, say you have two laptops in your
home and you want to write code in one laptop that communicates
with code in another laptop. How can you do that? This is what
socket programming allows you to do. And in order to master this level, you'll also find that you really
need to master the fundamental concepts of computer networking
before you master how to use libraries in Python that allows
you to do this socket programming. Let me clarify. For example, you need to understand
what TCP is, what UDP is. What's the difference
between TCP and UDP HTTP, which is also a very important
application layer protocol. And it's very widely used every time, just type google.com or Facebook.com
you're basically communicating via HTTP. So it's very important to understand how
these protocols actually work under the hood, because even if you're using
Python libraries that make
this job easier for you, these Python libraries, can't really abstract away all
of these concepts from you. So you really need to understand
these fundamental networking concepts before you start using these libraries,
that will make things easier for you. It's it's very important. Okay. I will link down below to my favorite
book about computer networking. It's written in a very engaging
way. It's not boring at all, and it will give you all the basic
fundamentals that you need to understand. And so that you can master
this level. Alright, after mastering these networking concepts, now it's time to write code again. So pull out your laptop and start
experimenting with a different Python libraries that allows you to
write network programs. For example, let me give you some examples. You will find libraries that allow
us to communicate over TCP or UDP. I started by writing something
called an echo program. An echo program is a simple program. It's like the hello world
for socket programming. So it requires at least two computers
because we want two computers to be talking to each other. One. Laptop is going to run the server side
of the program and another laptop will be running the client side of
the program, the server side. It's just going to be listening over the
network for any message that comes to this laptop and the client side program, we'll be sending messages to the
server side and what the server will do every time the server receives
a message from the client. The server will echo back this
message back to the client. So all of this action is actually
happening over the network. So if your two laptops are
connecting through wifi, these messages are actually communicated
over the wifi or over the land that you're having at your house.
Okay. It's, it's pretty cool. And the first time you write
the program, that's cool. [inaudible] between two computers. You'll be extremely happy because let's
be honest. It's, it's really magical. And it's beautiful when you,
when you get to do that. Another library in Python that is useful. If you want to write programs
that can talk over HTTP is to use their requests library from
Python. It really makes sure life easy. If you want to send an HTTP
packet to another computer, a very good exercise here is to
example, use Facebook or Twitter, both Facebook and Twitter, and most of
the services out there, web services, they provide an HTTP API interface so that your, your code can communicate
with them. In other words, basically you write a
post on your Facebook or basically post on your
Twitter from your Python code, by sending an HTTP packet to the Facebook server or the Twitter
server or Google maps. You can basically just get a navigation
from one point to another point by communicating to the Google map server. So this will be a great it's exercise
for you after you master this level well is to basically look at these services, look at their [inaudible] GP interfaces
and see how he can communicate to other API servers and do these
things. For example, like I said, just go to Twitter, look at their API documentation
and see what HTTP packet you should send in order to be able
to post a tweet, for example, using HTTP, but be careful
these different services. Most likely they will have
SDKs that to do this in Python, the easy way, but this is
not what you want here. You basically want to send a
pure HTTP using the requests library to the service. This is how you're going
to learn about HTTP. If you're using the SDK that
these services provide to you, you're not going to be
learning a lot here. Another thing that is very useful to
learn it, this level is learning all that, the different tools, networking tools that you can use
that only make your job easier, maybe troubleshooting your, your programs. If there's a bug or trying to understand
what really happens under the hood. I recommend looking at TCP dump, which is a terminal utility
or something like Wireshark, which is if you're more of a
user interface type of person, both of them do the same thing. The allow you to actually look at
the contents of the network packets that goes out of your machine to
another machine, which is very useful, especially when you're learning
the fundamentals of networks. It's very useful to use programs like
these because you'll be able to see the actual packets that eventually
goes to the wire or goes to the wifi. And you can see, you can, you can check
the contents of these packets. It's, it's amazing stuff. Of course, you don't really need to do that once
you start writing Python programs, but it's good from a learning
perspective. So yeah, TCP dump and Wireshark, lots
of documentation online. Level, number three, concurrent and programming
up to this level. The way we've been writing code is
have been writing sequential code. Meaning that the way we think
about the code that we write, we think that the code will
be executed sequentially. So every instruction in our code
will be executed sequentially. However, if we actually look at the underlying
hardware that our code is running on, for example, if we have a laptop, we have a processor with multiple cores, or we can sometimes have multiple
on the machine that we're using. So we need to learn and
understand how to take it. The vantage of this underlying hardware. And the way to take advantage of
that is to run pieces of your code in parallel so that your code runs faster
and more efficiently. Of course, that is if your code is paralyzable, if you can parallelize
your codes, however, writing parallel code is not easy, and there are a lot of bugs
that can happen in your code. If you're not paying
attention. For example, assume you have a shared variable X and
you have two processes that wants to increment X by five. You would expect that the final
value of X will be incremented by 10. However, if you're not careful, then you might find that the final value
of X is very different from what you expect. And the reason why this might happen is
because of something we call in computer science, race conditions.
What are race conditions? Basically, whenever you are trying to access a
shared the variable through different processes that are running in parallel,
then a race condition might happen. Meaning that the final value that you
would expect is going to be very different from what you get. If you want to know more about race
conditions and why they actually happen, I will link down below to an article
that explains more about why race conditions happen. Now, the question is
how to protect against race conditions. If we don't want our code to be
buggy, how do we protect against that? There are many mechanisms that
protect against race conditions. All of the mechanisms are called
synchronization mechanisms. One of the most popular synchronization
mechanisms is called the lockin mechanism. And
the idea is very simple. The idea is if you have
multiple processes and a process wants to read and write to S
Pacific shared the variable, then this process needs to
acquire a lock before it can read or write to this variable. And the idea is if the process
can't acquire a luck because it's acquired by another process, then the process has to wait until
the luck is released. So process one, for example, can acquire the lock and then
read and write two X and then release the law process to however can
not run in parallel with process one, because when process two, who
wants to, to acquire the luck, the luck is already acquired
by process. One process. Two has to wait until process.
One realizes the luck, and this is one of the many different
ways you can protect against a race condition. Alright, now everything that we've talked about
has been fundamentals about parallel programming in general. Now, if you
want to be specific about Python, here's what I want you to do. I want you to start writing parallel
programs using these three parallel modules, the threading
module, the Q module, and the multiprocessing module. All of these modules will
provide you with the primitives. You need to start writing
parallel programs. Another thing that is worth mentioning
here is if my application really needs efficiency, and if I really need to paralyze
the code that runs my application, then I'll probably not
use Python for that. I will probably use it something like
C plus plus or Java or go because these are more efficient languages
for parallel programming, and they utilize the underlying hardware
more efficiently level, number four, data structures and algorithms. So far, if you've mastered all the previous
levels that we talked about, you are an awesome quarter. My friend,
I can give you a task and you know how, how to solve this task. But that is not enough to
understand why that is not enough. Imagine the following scenario,
imagine that I am your manager. Okay. I ask you, here's a problem. I want you
to write code to solve this problem. So you go ahead, write some code and
fair enough, you answer the problem. However, when you give me your code, I run your code and it's
very slow. It's inefficient. It's running very slowly. So I
come back to you and ask you, Hey, can you make your code run faster?
Because it's, it's running very slow. And I don't understand
why here's the problem. You don't understand how to
make your code run faster. You don't even understand why your code
is running slowly in the first place. And the reason why that is because all
of the things that we talked about before in the previous levels, none of
these things talk about efficiency. None of these things talks about how
efficient your code is. And by efficiency, I mean either how fast your
code runs or how much resources does your code use. So in order to be able to answer to your
manager and actually make your code run faster, or even come back to
your manager and say, Hey, we can't truly make this code run faster
because of these reasons you really need to master data
structures and algorithms. This is what's going to take you
from being in average quarter, to being a solid programmer data
structures and algorithms. Again, it's a computer science subject. So a solid understanding of
data structures and algorithms. I'm going only to help you
in your Python journey. It's also going to help you if you want
to learn any other programming language as well. Some of the things that you
will want to learn is link lists, trees, graphs, hash tables, dynamic
programming, sorting algorithms, searching algorithms, and
so on and so forth. Again, this step is crucial. If you want to level up
and be a solid programmer, the last level advanced Python. So
this is the level when you take, take your Python learning
to the next level, this is going to be specific to Python.
And these are going to be the things, the concepts in Python
programming language that is
more advanced. For example, things like generators,
decorators, higher order functions, context managers coroutines and so on
and so forth. Metaprogramming as well. All of these are advanced
concepts in Python. And for that, I highly recommend a book
called flow into Python. This is my favorite book on
advanced Python concepts. It skips all the beginner stuff and
jumps right into the more advanced concepts that you need to learn. If you want to take your Python
mastery to the next level. Okay? So these are the six levels that
you have to go through in order to master the Python programming
language and in general, be a solid software engineer. However, depending on the kind of
application that you're writing, there are some libraries in Python
that can make your job easier, and you might find it useful to also learn
some of these libraries. For example, if you're writing API servers, then
I highly recommend you learn Flask. If you're writing web applications, then I highly recommend
you learn about Django. If you want to be a data scientist, if
you're interested in machine learning, then I highly recommend you learn
about scikit-learn and NumPy and pandas for numerical analysis, which goes hand in hand with
machine learning. Good luck. And I'll see you in the next video. [Inaudible].