HTML Diff
0 added 0 removed
Original 2026-01-01
Modified 2026-02-21
1 <p>This lesson will be about parameters. We will learn what parameters exist, how they differ, and when to apply them.</p>
1 <p>This lesson will be about parameters. We will learn what parameters exist, how they differ, and when to apply them.</p>
2 <h2>What parameters are available</h2>
2 <h2>What parameters are available</h2>
3 <p><strong>Arguments</strong>are the data passed to the function call. There are two types:</p>
3 <p><strong>Arguments</strong>are the data passed to the function call. There are two types:</p>
4 <p>The first type is<strong>positional arguments</strong>. We pass them in the same order in which we define the function parameters:</p>
4 <p>The first type is<strong>positional arguments</strong>. We pass them in the same order in which we define the function parameters:</p>
5 <p>The second type is<strong>named arguments</strong>. We pass them not as regular values but as a name=value pair. Therefore, we can write them in any order:</p>
5 <p>The second type is<strong>named arguments</strong>. We pass them not as regular values but as a name=value pair. Therefore, we can write them in any order:</p>
6 <p>We can look carefully at the two examples above and notice that the two functions are identical.</p>
6 <p>We can look carefully at the two examples above and notice that the two functions are identical.</p>
7 <p>Now we will discuss when we need to apply these types of arguments.</p>
7 <p>Now we will discuss when we need to apply these types of arguments.</p>
8 <h2>What parameters to use</h2>
8 <h2>What parameters to use</h2>
9 <p>The type of parameter you choose depends on who calls the function.</p>
9 <p>The type of parameter you choose depends on who calls the function.</p>
10 <p>There are two reasons to use named arguments:</p>
10 <p>There are two reasons to use named arguments:</p>
11 <ul><li><p>They increase readability because you can see the names at a glance</p>
11 <ul><li><p>They increase readability because you can see the names at a glance</p>
12 </li>
12 </li>
13 <li><p>We do not need to specify all the intermediate parameters because they are unnecessary at the moment</p>
13 <li><p>We do not need to specify all the intermediate parameters because they are unnecessary at the moment</p>
14 </li>
14 </li>
15 </ul><p>The latter point is if the function has many optional parameters. Let us look at an example:</p>
15 </ul><p>The latter point is if the function has many optional parameters. Let us look at an example:</p>
16 <p>Named arguments can be passed at the same time as positional arguments. In that case, the positional ones should go at the beginning:</p>
16 <p>Named arguments can be passed at the same time as positional arguments. In that case, the positional ones should go at the beginning:</p>
17 <p>In this lesson, we have limited ourselves to basic knowledge to help you read sample code with named arguments.</p>
17 <p>In this lesson, we have limited ourselves to basic knowledge to help you read sample code with named arguments.</p>
18  
18