Hello, my precious students.
And in this lecture, we will see some live, quote, examples regarding methods we we have learned
in the previous video what our methods, methods, BASIX basically, and we have seen method that does
not receive a very well.
And we have also seen an example of a method that does receive a variable.
So let's see some examples.
And once you open your project, create methods.
Live examples file.
All right.
And here also.
And right here, I just want to create a quick method, if you remember, there was a special special
word, special word key that indicates that we're dealing with a method and that word is def.
Right.
And then just create a new new method and you could call a salary salary calculation.
Just want to pay to get your intention to the following thing or in the beginning of the course, I
mentioned that we're going to discuss and we're going to focus on coding conventions.
Coding conventions is basically some agreed rules between all developers, and there are rules for each
each programming language separately.
So in Python, we also have coding conventions, meaning some accepted rules among developers worldwide,
which are dictated by the company that invented Python, basically.
So it's not that every person can invent its own his own rules.
So the conventions regarding variables we we have already discussed and basically these rules apply
upon methods as well.
So basically methods and variables have the same rules regarding coding conventions, coding conventions.
Basically, what is
relevant to this point is the naming of the naming.
This is like the big name of coding conventions goes down to the naming.
OK, so at this point, if you create methods so first of all, start the name of the method with small
letters and if you have more than one word in the naming.
So just separate them with another score.
So it's a very important rule to keep in order to stay professional and not to make fool of ourselves,
of ourselves once you get to job interviews and so on.
All right.
So this is our method called salary calculations.
And in here, I'm going to do a salary of the employee and it will be consist of salary variable multiplied
by 098.
Basically I reducing if I'm getting some kind of salary, I'm reducing two percent out of the whole
salary.
Once I multiplied in zero dark 98 and you can address this number as taxes for example.
All right.
It doesn't really have any meaning just for the practice.
All right.
So you can see right here we have the calculation and at the end, I just want to print it.
And the salary is.
Is the salary of the employee all right, so this is our method, OK, right here and this is our methods
content.
And basically we're missing one thing, which is this variable salary.
And as we've seen in the previous lecture, we first to in order for this method to be called or executed,
we need we need to execute it outside of the method itself.
So as long as they have intention, as long as I have like spaces here inside the method and right now
I'm going to press back but make space and now again at the beginning of the line here.
So that means that I'm outside of the method content.
I'm outside of this whole method thing.
And right now I'm just going to execute it.
And how they do it, basically, I just mention the method and also I want to pass some variable into
it.
I want to pass a salary variable.
And as you as you can guess, it's not a string variable because I'm not going to multiply a word upon
a number.
It's not logical.
So obviously, this number should be in some kind of number.
And I want to pass it from here.
This is point A and this is going to be point B and this is going to be point C, so you can check out
the previous lecture.
I discussed it in the last part there, that once we put the variable over here in the in the execution
part, this is the first point which the variable is inserted.
Then it goes up to the top to the methods declaration and from there it goes inside the method itself.
So if a board, for example, 1000 or maybe 10000 like this.
All right.
So right here it's back.
It has good brownish background because it's unexpected.
And why is it unexpected?
Because I didn't put it over here as well.
And here in the math, a declaration declaration of the variable should be the same, as I mentioned
it inside the method candidate content because they need to identify one another.
OK, so I'm just going to put salary here as well.
All right.
And now we're good.
OK, so I've sat here 10000 thousand then I'm just executing this method, meaning this one.
And I've said ten thousand here.
So basically here it's going to be equals to ten thousand at this point.
This does American here ABCDs as long as here inside, they also are going to have the same thing.
OK, then it's correct.
It doesn't matter what I put here, as long as it's the same thing that I have inside the methods content.
Right.
So I'm just going to put something meaningful here.
Also, this is one of the parts that our convention is very important.
Just to say, just to state your full names for variables.
I've seen lots of unexperienced programmers that put variables such as this cell, meaning it's short
of salary, but this is no good because I know if I wrote it, I know this the short of salary, what
someone else can come tomorrow on the on for for a year from now and read it.
And he will not understand what what he says.
All right.
He will not understand maybe from this reference right here, he can understand a salary ESL stance
for salary, but doesn't matter just you want to make easy life for your co-workers that work with you.
OK, so one of the main rules of professional programming is to put full names and not short names for
variables.
All right.
Like this.
So let's run this for for a second and see what we have.
All right.
So the salary is ninety eight hundred, as we expected from this print right here.
But look at this line if I want to put some other number here, OK, so I don't need to create an additional
method, OK, because this is just a variable.
This is a variable.
I can I can execute this method again with a different variable so I can make a separate line, remove
the brackets here.
I can create a separate line and put 5000 here.
OK, you see the beauty of it.
So I'm using this bulk of code as many times as I want in the code.
Just created it once and then I can execute it how many times I want.
Let's run it again.
You see the printout here, so I used it twice and I can use it a million times from now and I don't
need to create the calculation.
This part again and again for each variable that I've set here, don't need to do it.
Just do it once.
And that's it.
All right.
So this is the whole idea of this method, method, trick.
This is very important for object oriented programming.
Our next topic.
So it's a very useful and very meaningful part in programming in general.
All right.
I also just want to show you a new trick that we haven't started yet.
We can put several variables here.
So if I put, for example, the multiplication number or maybe like tax reduction.
OK, so I could put two variables here inside the method declaration as long as I put here also two
numbers as well.
And then just I'm going to remove this one.
OK, ok then 098 just put two variables here.
OK, then he asks me to put two as well and these two as well.
You see, you see here when a hover parameter tax reduction on field.
So it demands me to put it demands me to put two variables and now it's more dynamic because now I can
put one time the tax reduction to be 098 in a different time.
For example.
It's a different country.
I can put different tax.
So it's very flexible and you see the beauty of it because you can put you whatever you want.
So once I have here 098 this called hardcoded, this is the term hardcoded variable hardcoded means
that you can't change it.
It stays still forever.
The same number, but now it's not hardcoded.
Now it's advanced and it's dynamic.
OK, so each time I owe, each time I execute this method, I can put different variables for tax reduction
and different variables for salary.
Let's see how it goes.
Let's run it.
OK, we have some kind of problem here.
Of course, I don't have a comma.
All right, OK.
So everything's fine, so we put the celery here and we put the tax reduction over here.
Great.
So this summer's off the basic part of math.
You can see it's very simple.
You can put one variable here or even two variables here as long as you put also two variables in the
execution line.
And also it can execute it as many times as you want, each time with different variables inside the
method.
So it's a very flexible and you can see why it's very important in programming.
All right.
That sums up this lecture I will see in the next one.
Thank you.
Wemba by.