All language subtitles for 2. Functions - Basic Structure

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

What is going on, guys?

And welcome back to another video where we are going to talk about functions.

So in this lesson, I would like to keep showing you how much these functions topic is not so scary.

And I do this by simplifying things to the simplest level for you.

Don't worry if we haven't seen this code for functions just yet.

Trust me that these preparation is far from being less important than jumping straight to the code.

So now let's make another brief analogy.

Let's say that we have John.

John is a function.

He sits in his room and he knows that all he has to do whenever someone calls him is to receive three

numbers, calculate the average and return to return the result to whoever call him.

OK, so let's talk in more details about how John operates.

So, first of all, it's very important to understand that that every function has a name and that this

name should be unique because we want to be able to separate, to distinguish between all of these different

functions that we may have, just like we've done it with variables.

So we know, for example, the name of the function is John.

And there also may be other functions like let's say we just call them.

This way, Sara, Mike.

And so on and so forth.

We will also talk more about proper naming scene programming as we go into these section and as we go

to the more advanced courses when we are going to discuss it.

So once again, let's say that John is some guy with some specialty and he is inside of his room.

It's John's room and John receives three numbers.

So whenever we would like to come to John's room, John will await to receive from us three numbers.

And these three numbers that John expects to receive are called parameters.

We will say that every function may expect to get some parameters.

The function may expect to receive one, two or even five parameters.

That's usually not limited to some number of parameters that the function may expect to get.

But usually functions are not being used with plenty of them.

And also, the function may not expect to receive any parameters at all.

Right.

It may expect to receive zero parameters.

That's all depends on the function itself.

And to summarize, think of this step when the functional receives parameter says when these John guy

stands at the entrance of his room expecting to receive the relevant parameters.

And when you're going to use it some function, know that this function.

This guy who stands at the front door expects to, first of all, obtain some parameters before it starts

executing its code.

So before John will start executing all of its code, all of its core, all of its war, its specialty

of what it was created for, it, a ways to receive some parameters that may be useful for his execution

of these code.

OK.

And once the function received its list of parameters, our function, our John Boy is going to close

the door and start doing his thing.

So his task, his thing may be to calculate the average grade or find the maximum or print something

to the screen or anything else.

And this task is accomplished by executing the commands of this function.

So these different commands or far functions are called the functions body.

And in the functions body, you may have usage of different local variables, which are just variables

local to the specific space of the function, to the specific room that the function and security code.

Now these local variables are just local to jawans room.

We as an outsider as basically can not use these variables at all.

Right.

They are in a totally different room.

And aside from local variables that may be created in this room, the function may have different assignment,

mathematical input and output operations as well.

And all of these things, all of these types of things, all of the core of the function is simply called

the functions body.

And that's basically one of the things that we are going to focus on in most of these section.

So once again, we know that at the functions body, while the door was closed, all the desired code

has been executed.

And once the function is done executing its code, it may open the door and return something.

Some results, some value to.

Never called it.

So suppose for this example, you've come to John when we know John is a function, we gave John three

numbers of our grades.

And then John executed the commands to calculate the average grade.

Once he's finished, we expect the John or better say the function.

Right.

We'll open the door and return as a result.

For example, the average grade itself.

Right.

We expect that, John.

We'll give us the average grade at the end.

Right.

That he will return us.

That the function will return as something some result of its execution.

So we, as the callers who called the function, may expect the function to return as something.

Once it's finished.

So John may return something to us.

And this something may be of different types.

It may be of an integer, a.

A floating point type, a character or any other type.

And that's simply called the return type.

The function type.

So if in this case we know that a function should return the average grade, then we can say that this

result is going to be of a floating point type.

That's why we can say that the function type, the return type is going to be a floating point.

And it's very important to know what type of value every function is expected to return.

Before you even use it, because, I mean, you want to know what you should expect to get when the

function has done, executing its commands.

And now the door opens when when the door opens and the function returns you something you want to know,

where should you store eating?

What type of variable?

Right.

So I hope that's clear.

And please know that the function may return some type of value, but it may also not return anything

at all.

It all depends on how we define our function.

And we'll talk about this more.

And you will understand much more in the following examples that we have in this section.

So to summarize everything out.

That's how you categorize a function.

First of all, you understand that every function should have its own name.

So then you can call this function by its name whenever you like.

Then you specify for that function the list of parameters that the function is expected to receive.

These parameters may be, of course, of different types.

Also, you know that the function that John should do something, the function should have some commands

associated with it.

And these commands are called the functions body.

That's exactly where we specify the content of the function and we will see more health.

How how you really do it in code?

In our examples and in our challenges.

And lastly, for every function, you should specify the type of data it's expected to return.

Will that be an integer, a floating point?

Or maybe the function should not return anything at all.

Just specify these information for your function.

And with that being said, I hope that everything is clear and you understand the concept and the general

structure of how functions look like.

And that you are ready to move on.

So thank you guys for watching.

And in the next video, we are going to talk about how everything that we've learned in this video looks

like in our programming language.

So I'll see you there.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.