1 00:00:00,570 --> 00:00:04,440 Andrei: Let's talk about arguments versus parameters, 2 00:00:04,440 --> 00:00:06,660 which is one of our key terms 3 00:00:06,660 --> 00:00:10,470 that we use when describing functions. 4 00:00:10,470 --> 00:00:12,480 Let's see what they mean. 5 00:00:12,480 --> 00:00:16,980 You see, right now our say hello function is pretty generic. 6 00:00:16,980 --> 00:00:17,820 Very simple, right? 7 00:00:17,820 --> 00:00:20,758 We're just, well, printing hello. 8 00:00:20,758 --> 00:00:24,510 It's kind of useful, but not really. 9 00:00:24,510 --> 00:00:27,120 The power of functions 10 00:00:27,120 --> 00:00:30,240 beyond just being able to call this multiple times, 11 00:00:30,240 --> 00:00:33,390 because it only lives in one location in memory, 12 00:00:33,390 --> 00:00:37,950 is this ability for us to make it dynamic. 13 00:00:37,950 --> 00:00:40,320 For example, in these brackets, 14 00:00:40,320 --> 00:00:43,500 I can give it what we call parameters. 15 00:00:43,500 --> 00:00:47,500 So in here, we give it parameters 16 00:00:50,280 --> 00:00:51,780 inside of the bracket. 17 00:00:51,780 --> 00:00:54,220 So for example, I can give it name 18 00:00:55,500 --> 00:00:57,780 which is a variable that I just made up. 19 00:00:57,780 --> 00:00:59,250 I can call whatever I want. 20 00:00:59,250 --> 00:01:00,720 And I can leave it like that 21 00:01:00,720 --> 00:01:03,810 or I can keep giving it parameters as many as I want. 22 00:01:03,810 --> 00:01:06,003 I can keep adding a hundred if I wanted to. 23 00:01:07,290 --> 00:01:10,563 So in this case, let's just say this is an emoji. 24 00:01:11,520 --> 00:01:16,350 So these are two variables or parameters that I've created. 25 00:01:16,350 --> 00:01:20,530 And this say hello function is able to receive 26 00:01:21,600 --> 00:01:23,160 these two parameters. 27 00:01:23,160 --> 00:01:24,180 What does that mean? 28 00:01:24,180 --> 00:01:27,150 It means that we're able to use these variables 29 00:01:27,150 --> 00:01:28,980 inside of this function. 30 00:01:28,980 --> 00:01:33,450 For example, I can create this as an f string 31 00:01:33,450 --> 00:01:38,450 and say hello and add the name, 32 00:01:40,050 --> 00:01:43,860 and then finally add the emoji. 33 00:01:43,860 --> 00:01:45,930 And because I have these as parameters, 34 00:01:45,930 --> 00:01:49,950 I can use them as variables inside of this code block. 35 00:01:49,950 --> 00:01:54,950 Now, these parameters allow us to give the function 36 00:01:55,950 --> 00:02:00,390 when we call it, what we call arguments. 37 00:02:00,390 --> 00:02:01,260 And by the way, 38 00:02:01,260 --> 00:02:03,690 the confusion between parameters and arguments, 39 00:02:03,690 --> 00:02:06,750 people usually say one when they mean the other. 40 00:02:06,750 --> 00:02:08,430 It's a little tricky. 41 00:02:08,430 --> 00:02:09,930 So hang in there. 42 00:02:09,930 --> 00:02:14,550 Arguments are used as the actual values 43 00:02:14,550 --> 00:02:16,623 we provide to a function. 44 00:02:17,730 --> 00:02:21,090 So now, in say hello, I can give it a name. 45 00:02:21,090 --> 00:02:24,450 In my case, let's just say hi to myself. 46 00:02:24,450 --> 00:02:27,300 And then, I can give it an emoji. 47 00:02:27,300 --> 00:02:31,800 And you see how my editor is giving me the hint 48 00:02:31,800 --> 00:02:33,480 that I should give it an emoji 49 00:02:33,480 --> 00:02:35,550 because, well, I defined it here. 50 00:02:35,550 --> 00:02:38,070 Again, something that editors help us do. 51 00:02:38,070 --> 00:02:39,270 So let's just give it 52 00:02:39,270 --> 00:02:41,370 just a smiley face with the tongue out. 53 00:02:41,370 --> 00:02:43,800 Now, these are arguments. 54 00:02:43,800 --> 00:02:47,370 These are the actual value we provide to the function. 55 00:02:47,370 --> 00:02:51,240 And the name of the variables that we use, 56 00:02:51,240 --> 00:02:53,970 that we receive are called parameters. 57 00:02:53,970 --> 00:02:57,780 So parameters are used when we define the function 58 00:02:57,780 --> 00:03:01,383 and arguments used when we call the function. 59 00:03:02,280 --> 00:03:04,440 Define and call. 60 00:03:04,440 --> 00:03:08,250 And by the way, some people also like saying call 61 00:03:08,250 --> 00:03:12,540 or invoking the function or invoke the function. 62 00:03:12,540 --> 00:03:15,513 So if you ever hear those words, you know what they mean. 63 00:03:16,740 --> 00:03:21,740 So if I run this, I get Hello Andrei with that smiley face. 64 00:03:24,150 --> 00:03:28,110 And this is when functions get really powerful. 65 00:03:28,110 --> 00:03:31,560 Because we're able to not just make generic functions 66 00:03:31,560 --> 00:03:33,270 that always do the same thing, 67 00:03:33,270 --> 00:03:36,210 but we can create functions that do things 68 00:03:36,210 --> 00:03:38,980 based on what parameters we give it 69 00:03:39,990 --> 00:03:42,633 or what arguments we call it with. 70 00:03:43,710 --> 00:03:47,130 So that now I can use the say hello function 71 00:03:47,130 --> 00:03:51,150 to say hello to my friend Dan, 72 00:03:51,150 --> 00:03:54,210 and also my friend Emily. 73 00:03:54,210 --> 00:03:58,983 And if I click run, we've made our function more extensible. 74 00:04:00,030 --> 00:04:02,130 We can use it in multiple places. 75 00:04:02,130 --> 00:04:04,560 And if we're designing a game, 76 00:04:04,560 --> 00:04:07,950 well, we've just used this to greet our users. 77 00:04:07,950 --> 00:04:09,540 And based on the username, 78 00:04:09,540 --> 00:04:12,843 I can use the same function over and over. 79 00:04:13,680 --> 00:04:16,860 Again, we're keeping our code dry and clean 80 00:04:16,860 --> 00:04:18,690 by doing something like this. 81 00:04:18,690 --> 00:04:20,403 How cool is that? 82 00:04:21,779 --> 00:04:23,220 All right, let's take a break. 83 00:04:23,220 --> 00:04:24,970 And I'll see you in the next video.