1
00:00:04,970 --> 00:00:09,740
Our multiply function isn't very useful.
It multiplies 10.5 by 4 and

2
00:00:30,300 --> 00:00:31,680
Alright, so we're going to get our function

3
00:00:31,680 --> 00:00:36,180
to multiply two numbers, then
return the result. To do that, we need

4
00:00:36,180 --> 00:00:40,540
some way to get the numbers into the
function, so that it knows what to multiply,

5
00:00:40,540 --> 00:00:44,800
rather than hard coding the numbers, as we're doing on line 2. So this is what

6
00:00:44,800 --> 00:00:48,560
function parameters are for. So I'm going
to add two parameters to our function,

7
00:00:48,560 --> 00:00:55,460
so I'm going to come up here, and within the
parentheses I'm going to type x comma space y.

8
00:01:17,160 --> 00:01:19,260
Alright, so now that we've declared two

9
00:01:19,260 --> 00:01:23,160
parameters in our function, we can use
them instead of the hard-coded literal

10
00:01:23,160 --> 00:01:29,500
values on line two. Let's go ahead and do
that. I'm going to change a 10.5 to x, and 4,

11
00:01:29,500 --> 00:01:34,920
I'm going to change to y. Whatever 
values we provide for those parameters,

12
00:01:34,920 --> 00:01:39,320
will be used when we call the function. 
When a function has parameters,

13
00:01:39,320 --> 00:01:44,039
you must provide suitable values when
you call the function. Now it's hard to

14
00:01:44,039 --> 00:01:48,329
see this because of the break point, but
I've got a warning on line six. If I hover,

15
00:01:48,329 --> 00:01:51,549
now, over the parentheses after the function name,

16
00:01:51,549 --> 00:01:55,160
you can see that IntelliJ is telling me
that parameter x is unfilled,

17
00:01:55,160 --> 00:02:01,540
and parameter y is unfilled. We can fix that
by providing the arguments.

18
00:02:26,460 --> 00:02:29,320
So the multiply function defines two parameters,

19
00:02:29,320 --> 00:02:33,460
so we now have to provide two 
arguments when we call it. I'm going to

20
00:02:33,460 --> 00:02:38,680
to do that by entering those in the
parentheses on line six: 10.5 comma

21
00:02:38,680 --> 00:02:43,000
and 4. Now that fixes the error,
so it's now ready to run the program.

22
00:02:43,010 --> 00:02:45,880
So let's run the program,

23
00:02:46,260 --> 00:02:52,360
and unsurprisingly, we get 42.0 printed
out again. Because we've used parameters,

24
00:02:52,360 --> 00:02:56,400
we can use our multiply function to
multiply different numbers. So as an

25
00:02:56,400 --> 00:03:05,300
example of that, we can type 42, 40
underscore 2, is equal to multiply,

26
00:03:05,300 --> 00:03:13,100
and we'll pass two arguments, 6 and 7 - 6 comma 7.
Let's print it out to confirm it, print 42.

27
00:03:13,100 --> 00:03:16,060
Run the program.

28
00:03:17,000 --> 00:03:21,410
This time we've got 42 printed out as an
integer. When you multiply two ints, the

29
00:03:21,410 --> 00:03:26,270
result is int.  We can use our multiply
function in a loop, as well. In fact, we

30
00:03:26,270 --> 00:03:31,100
can use it anywhere that Python expects
an expression. A function call is another

31
00:03:31,100 --> 00:03:35,210
type of expression. Let's put some more
code in here. What I'm going to do is,

32
00:03:35,210 --> 00:03:42,940
close down the output pane. Line 12, I'm
going to print an empty line, then line 14,

33
00:03:42,940 --> 00:03:50,780
for val in range, parentheses 1 comma 5
closing parenthesis and a colon. We're

34
00:03:50,780 --> 00:03:57,220
going to put two underscore times is
equal to multiply, and in parentheses,

35
00:03:57,220 --> 00:04:08,400
two comma vowel. Then on the next line, we'll print
two_times. Run this program now,

36
00:04:11,160 --> 00:04:15,020
and you can see what's happened there - our
loop has multiplied the values from 1 to 4

37
00:04:15,020 --> 00:04:20,200
by 2. As you can see, multiply is now
a little bit more useful. We can tell it

38
00:04:20,200 --> 00:04:24,160
which two numbers to multiply and it
returns the result. It's still not a very

39
00:04:24,160 --> 00:04:27,760
exciting function, but it does
demonstrate how the formal parameters

40
00:04:27,760 --> 00:04:32,260
are given values, by the arguments that
we pass when calling the function.

41
00:04:32,260 --> 00:04:35,980
In the next video, we'll run the program in
the debugger, and see how the arguments

42
00:04:35,980 --> 00:04:42,000
are used in place of the formal
parameters. See you in the next video.

