1
00:00:00,660 --> 00:00:03,540
We're going to see what the python functions.

2
00:00:03,960 --> 00:00:10,960
So let me tell you an example, suppose you have a hundred lines of code to calculate, uh, the area

3
00:00:10,960 --> 00:00:15,470
of something and you want to repeat it four or five times.

4
00:00:15,480 --> 00:00:21,370
So you cannot copy paste those 100 lines of code five times to calculate some value.

5
00:00:21,540 --> 00:00:24,540
So what you're going to do is you are going to write a function.

6
00:00:24,910 --> 00:00:29,760
It will do the calculations for you and it will return some result to you.

7
00:00:30,090 --> 00:00:35,160
So if you want to call it 10 times, you don't need to copy those hundreds of code.

8
00:00:35,160 --> 00:00:39,820
And we can just simply call this function 10 times and you'll get 10 values.

9
00:00:40,050 --> 00:00:41,560
So this is very simple.

10
00:00:41,790 --> 00:00:43,890
So let's get started.

11
00:00:45,450 --> 00:00:49,810
So now let's say function need to define the function.

12
00:00:50,160 --> 00:00:51,600
So we need to use the def.

13
00:00:51,990 --> 00:00:53,590
So define the function.

14
00:00:54,300 --> 00:01:01,320
Let's calculate to work on the area.

15
00:01:02,700 --> 00:01:04,230
So this is my function.

16
00:01:04,410 --> 00:01:05,490
I want to do so.

17
00:01:05,490 --> 00:01:11,520
I want to put the, uh, open brackets and I need to parse some arguments.

18
00:01:12,000 --> 00:01:17,070
So generally, what will be the arguments are to the area of a rectangle.

19
00:01:18,390 --> 00:01:18,750
Right.

20
00:01:19,920 --> 00:01:21,410
So I can say a flawed.

21
00:01:22,810 --> 00:01:34,270
And and throat beat, so I can like this and I concert a colon and then the interrogation goes on and

22
00:01:34,270 --> 00:01:44,560
you need to write some code that will calculate the lantern to breath so that the area is equal to allow

23
00:01:44,560 --> 00:01:45,330
in to be.

24
00:01:47,320 --> 00:01:53,620
So this is a sample code I'm going to tell you of because there are so many advanced calculations you

25
00:01:53,620 --> 00:01:54,040
can do.

26
00:01:54,040 --> 00:01:56,710
But this is just for practical example.

27
00:01:58,630 --> 00:02:05,140
So I can use this function and I can pass some values of the length and breadth to calculate this area.

28
00:02:05,710 --> 00:02:10,240
So now I want to see is equal to.

29
00:02:12,560 --> 00:02:14,020
Gary, great area.

30
00:02:17,000 --> 00:02:19,830
Off I want to sell and interpret for you.

31
00:02:19,850 --> 00:02:20,580
Come on, sir.

32
00:02:22,250 --> 00:02:25,990
Well, it's obvious seven come off right now.

33
00:02:26,960 --> 00:02:31,160
This call will executer and this area will be in dysfunctionally.

34
00:02:31,340 --> 00:02:36,530
So this area is called local, where local will work to this Takrit area.

35
00:02:36,710 --> 00:02:45,860
If you access this area outside of this function, the U.S. area, because this local variable and it

36
00:02:45,860 --> 00:02:49,960
will be only defined only into this function.

37
00:02:50,540 --> 00:02:56,810
So to access this one, you need to return the value in a certain area.

38
00:02:57,620 --> 00:03:06,800
So what this means is whenever you are doing the Callcredit area, R7 come off and this function will

39
00:03:06,800 --> 00:03:13,030
be called and elsewhere, you can determine and be very contentious and it will be corrected and it

40
00:03:13,040 --> 00:03:13,550
will return.

41
00:03:16,200 --> 00:03:21,800
So the return value will be stored in the seat, so you can think like this is a seat is equal to area

42
00:03:21,810 --> 00:03:25,590
area, which represents this variable, the variable value.

43
00:03:27,930 --> 00:03:33,330
And let me comment on this one and let me run the program.

44
00:03:51,480 --> 00:03:52,040
All right.

45
00:03:54,600 --> 00:04:03,420
I'm sorry, I just to find, like other programming languages, sorry, you don't need to define fraud

46
00:04:03,420 --> 00:04:10,630
or any you can just say cover the and the values will be automatically restored dynamically as integer

47
00:04:10,680 --> 00:04:12,740
or the string or whatever you pass.

48
00:04:13,410 --> 00:04:20,290
So you do not get any output because by default, functions cannot get executed until they are called.

49
00:04:20,910 --> 00:04:26,140
So calling the function without mentioning the function somewhere in the code.

50
00:04:27,210 --> 00:04:31,590
So this is the function template and this should be top of the calling code.

51
00:04:31,620 --> 00:04:39,720
So my code is calling here and the function should be, uh, before this one because the interpreter

52
00:04:39,720 --> 00:04:41,120
starts from top to bottom.

53
00:04:41,130 --> 00:04:45,700
And if this line is, uh, here, then it gives you an error.

54
00:04:45,720 --> 00:04:48,080
So that's why we need to define functions first.

55
00:04:48,720 --> 00:04:51,690
And so we are not going to call this function.

56
00:04:52,570 --> 00:04:53,760
Let's execute this one.

57
00:04:56,240 --> 00:05:00,860
So we do not print anything, let's print where we have seat.

58
00:05:03,280 --> 00:05:04,510
So we got to testify.

59
00:05:06,460 --> 00:05:13,960
So we called the function and it has calculated the value, suppose if you want to define some function

60
00:05:13,960 --> 00:05:21,670
and you do not want to assign any value or you want to leave that for the future properties, then want

61
00:05:21,670 --> 00:05:24,610
to increase its function.

62
00:05:28,130 --> 00:05:37,190
And then you can pass, so this daughter pursues this path to reserve some area of space for this function,

63
00:05:37,190 --> 00:05:38,460
for the future of this.

64
00:05:38,690 --> 00:05:50,060
So if you want to set up that so you can start working on this subject whenever the time comes out in

65
00:05:50,060 --> 00:05:54,250
the future, if you want to update any function, you can just put the past.

66
00:05:54,710 --> 00:06:00,830
And if you remove this pass, you'll get the error because there should not be an empty function.

67
00:06:02,990 --> 00:06:05,990
So as you can see, demolition expert.

68
00:06:08,900 --> 00:06:10,830
So this one is in transition.

69
00:06:10,850 --> 00:06:16,450
It is something that you should not be like empty function, you need to put the viewer on this.

70
00:06:16,910 --> 00:06:19,100
Now, the program exudes character.

71
00:06:21,390 --> 00:06:24,570
So you can also also bring something.

72
00:06:38,390 --> 00:06:40,160
So now I'm going to call this function.

73
00:06:43,330 --> 00:06:50,770
Since this function is not returning anywhere values, I just need to start anything I can just simply

74
00:06:50,770 --> 00:06:52,390
call this function on this.

75
00:06:55,020 --> 00:06:57,250
And you can see the output has been blah, blah, blah.

76
00:06:57,870 --> 00:06:59,500
It has been from this function.

77
00:07:00,060 --> 00:07:02,930
So that's all the basic concepts about the function.

78
00:07:02,940 --> 00:07:05,050
We are going to view only the basic concepts.

79
00:07:05,370 --> 00:07:14,400
There are also some intermediate concepts like verbal and arguments, but it's really more for discourse

80
00:07:15,000 --> 00:07:16,500
and just not work.

81
00:07:16,740 --> 00:07:18,180
Functions are fine for us.

