Hello and welcome to this lecture.
And from this section onwards you are actually going to learn some of the best practices which we need
to follow while we write any kind of Python code.
So a lot of courses do not include the section on how to write effective Python code or how to write
clean code which is understandable by those.
And according to me this is one of the most important parts of it.
You need to learn not only how to write syntactically correct code but also if you wish to work in an
organization some day as a Python available you obviously need to know how to write clean Python code.
So this is going to be an introductory lecture and we will learn why we need to write clean Python code
or effective Python code and fun.
The next lecture on words we're going to learn about the best practices about writing Python code.
So I will be adding more and more lectures to this body section as we move ahead.
But for now we are going to go to some of the basic things which we need to remember while writing Python
code.
OK so let's get started with this particular lecture.
So I have laid out three reasons here for writing clean Python code.
So the very first reason is that your code must actually be readable.
And what I mean by readable is that let's say if you're working in an organization as a Python developer
and let's say you're working on a project where you need to design a certain functionality.
So for designing that particular functionality you have to write a bunch of code which will include
a bunch of functions.
So let's say you have build one particular function which does a particular job.
So what happens is that when you collaborate with other programmers in your organization and when the
program actually takes a look at your code he must be able to identify what the particular block of
code does.
So if your code is not readable that is if your coworker is not able to understand what your code actually
does then he might feel confused and then such kind of code is actually called as unreadable code.
So let's take an example of what a readable code an unbeatable code looks like.
So let's dig a simple example of adding two numbers so let's say you have to create a function for that.
So you type of and numbers and after that let's go ahead and add two numbers up by passing them over
here.
So that's going to be let's see.
Come on be and let's say you add these two numbers and see it in to see.
So as you could see by looking at this particular function you could easily make out that this thing
actually performs the addition of two numbers.
But this is actually a simple example of function but in real life scenario you actually need to go
ahead and write a lot of complex functions.
And that's actually not going to be easy to identify what those functions actually do.
So in order to make your code readable what you could do is that you could name your functions in a
proper way.
So what you could do is that you could define a function name such that the function name itself suggests
what the function actually does.
So for example as you could make out from the function name that this function actually adds up to numbers.
Now what if you actually name a function something like let's see function do so syntactically this
function name is actually correct.
But if your code actually contains some complex things then it absolutely becomes impossible for either
person to determine what your function actually does.
So instead of giving functions random names you should always give suggestive names.
So just what the function actually does.
So the proper name for this thing should be and numbers.
So this is one of the examples of why you should write a readable code.
So I hope you guys were able to understand this point Deut.
Here now let's go ahead and learn about collaboration.
So as I mentioned if you're working in an organization you do need to collaborate in teams to write
a particular software.
So each of your members will be working with a different piece of software different piece of functionality
for a particular software version you have to write different lines of code.
So then you work with people rather than working and usually your code should not only be understandable
or readable by you but also the people who are working with you should also be able to read your code
so that is the main reason for writing readable code that other people understand it.
Obviously as you have written your code no matter how bad you do it you will be able to understand it
because it is written by you.
But then some other person has a look at your code he should be able to figure out what the code actually
does and that thing plays a crucial role.
When you collaborate in teams now the third most important point here for writing clean Python code
is that the correct syntax is not enough.
So if you write some code which is syntactically correct it doesn't necessarily mean that your code
is clean.
Because as I mentioned you could name this function as anything and still it's going to work but that
does not mean that your code is clean.
So this is a basic introductory lecture on how to write clean Python code and why you should actually
write clean Python code.
And in the next election would We're actually going to go into much more depth in this particular concept
because in order to become a professional Python programmer or any programmer for that matter you do
need to learn the art of writing clean and efficient code.
So thank you very much for watching and I'll see you guys next time.
Thank you.