Functions (Programming Basics)

preview_player
Показать описание

▬▬▬▬▬▬▬▬▬▬▬▬ FOLLOW ME ▬▬▬▬▬▬▬▬▬▬▬▬

▬▬▬▬▬▬▬▬▬▬▬▬ MY GAMES ▬▬▬▬▬▬▬▬▬▬▬▬

A function is like an employee that has a very specific task. That task could be to calculate the distance between two points, to control the behavior of a game character or to display our variables to the screen like we just did with the print function.
As a programmer, you're the CEO of your own little business, which is your program.
You have a lot of data to manage which are you all variables and if you want to do something with all of that information you need the help of your employees.
In the real world, those employees have names like John or Brian. In the program an employee will have a name that sounds more like print or or debug or display but it's exactly the same principle.
That's all we're doing in a program. We create a lot of boxes with information we need and we manage our employees to accomplish the goal of our business, whether it be creating a website, a robot or a game.
Sometimes, to accomplish their task we need to give an employee some information. For example, the task of our print function is to display a message on the screen. To do that, we need to give it the information we want it to display, which is what we've done by writing the name of our variable between the parentheses. The variables that we need to give a function so they can accomplish their tasks are called parameters or arguments of that function. Here, we can say that our print function has one parameter or one argument.
print is a function that already exists and there are others like open or close that we can use to open or close a file on our computer.
But we can also create our own functions and define what they will do.
Рекомендации по теме
visit shbcf.ru