1
00:00:00,610 --> 00:00:01,300
Hello, dear friends.

2
00:00:02,320 --> 00:00:09,040
So in this lesson, we will learn inheritance, which is pretty much the most important subject of object

3
00:00:09,040 --> 00:00:10,060
oriented programming.

4
00:00:10,870 --> 00:00:11,620
I'll show you why.

5
00:00:11,650 --> 00:00:12,370
So let's start.

6
00:00:14,410 --> 00:00:18,040
So this is what we've learned so far about object oriented programming.

7
00:00:19,030 --> 00:00:24,310
And again, I will share with you what we've learned in this table in every lesson until the end of

8
00:00:24,310 --> 00:00:24,820
our topic.

9
00:00:25,660 --> 00:00:26,950
So we'll continue our lesson.

10
00:00:28,600 --> 00:00:34,390
So basically, inheritance is when a class inherits properties and methods from another class.

11
00:00:35,050 --> 00:00:41,650
So we can think of inheritance as well, some of the inherited traits that we inherited from our parents.

12
00:00:41,890 --> 00:00:43,270
Now, no judgment here.

13
00:00:43,930 --> 00:00:47,420
But what is a father passed to a son?

14
00:00:47,440 --> 00:00:47,710
Right.

15
00:00:47,920 --> 00:00:52,150
So inheritance in Python has very similar logic.

16
00:00:53,050 --> 00:00:53,360
Right.

17
00:00:53,380 --> 00:00:56,200
And again, with no judgment, we like Python.

18
00:00:56,830 --> 00:00:58,660
So where can we use it?

19
00:00:59,200 --> 00:01:00,950
Well, well, imagine a school.

20
00:01:00,970 --> 00:01:05,890
And in this school, there's a headmaster, deputy headmasters, teachers, students.

21
00:01:06,370 --> 00:01:11,200
Now, if we want to create a different class for each of these some of these classes, well, while

22
00:01:11,220 --> 00:01:17,980
they'll have the same attributes like name and surname, birthday and all that, then instead of defining

23
00:01:17,980 --> 00:01:24,940
these common properties and methods in these classes over and over again, we can define one main class

24
00:01:25,210 --> 00:01:30,010
and then get them to give the attributes and methods of this class.

25
00:01:31,180 --> 00:01:33,700
So that's the logic of inheritance.

26
00:01:34,810 --> 00:01:37,000
Let me just show you how to use it and then you'll see.

27
00:01:38,080 --> 00:01:42,760
So we'll define a new class named teacher class teacher.

28
00:01:44,970 --> 00:01:51,930
Attributes her name, surname, birth, date, profession, gender, classroom, death in it.

29
00:01:52,970 --> 00:01:53,630
Selv.

30
00:01:54,620 --> 00:01:57,380
Name, surname, profession.

31
00:01:58,810 --> 00:02:00,550
Classes, gender.

32
00:02:02,120 --> 00:02:02,780
Birth date.

33
00:02:05,590 --> 00:02:11,680
Self-doubt, name equals name, self-taught surname equals surname.

34
00:02:12,630 --> 00:02:15,840
Self-taught profession equals profession.

35
00:02:17,800 --> 00:02:20,830
Self-taught glasses equals classes.

36
00:02:22,490 --> 00:02:24,890
Self-doubt, gender equals gender.

37
00:02:25,870 --> 00:02:28,960
Self-taught birthdate equals birth date.

38
00:02:31,450 --> 00:02:41,770
All right, so again, define the show info method, def show info, self print, employee information.

39
00:02:47,720 --> 00:02:48,770
And name.

40
00:02:52,300 --> 00:02:53,410
Self doubt name.

41
00:02:56,610 --> 00:02:57,810
And surname.

42
00:02:59,530 --> 00:03:00,910
Self-taught surname.

43
00:03:05,190 --> 00:03:06,390
And profession.

44
00:03:10,840 --> 00:03:12,310
Self-taught profession.

45
00:03:19,040 --> 00:03:20,180
And classes.

46
00:03:22,110 --> 00:03:23,430
Self-taught classes.

47
00:03:25,310 --> 00:03:26,420
And gender.

48
00:03:28,930 --> 00:03:30,160
Self-doubt, gender.

49
00:03:34,210 --> 00:03:35,470
And birth date.

50
00:03:38,440 --> 00:03:40,090
Self-taught birthdate.

51
00:03:42,080 --> 00:03:48,770
All right, so now let's create a new class named headmaster and we inherit from the teacher class.

52
00:03:51,420 --> 00:03:53,340
Will define a method later.

53
00:03:54,420 --> 00:03:56,460
But this is why we use a past statement.

54
00:03:58,040 --> 00:03:58,580
Pass.

55
00:03:59,540 --> 00:04:04,940
OK, so let's create an object named headmaster, one using the head master class.

56
00:04:05,990 --> 00:04:06,800
Headmaster.

57
00:04:13,100 --> 00:04:13,610
John?

58
00:04:15,280 --> 00:04:15,760
Though.

59
00:04:17,750 --> 00:04:18,590
Headmaster.

60
00:04:20,310 --> 00:04:20,930
None.

61
00:04:21,400 --> 00:04:21,930
Male.

62
00:04:23,560 --> 00:04:26,410
Zero one Jan one nine seven eight.

63
00:04:30,070 --> 00:04:34,660
OK, so now we want to see the info, headmaster one.

64
00:04:36,320 --> 00:04:37,730
Dots show info.

65
00:04:40,850 --> 00:04:45,800
And as you can see, we didn't define anything for the head master class, but it took the teachers

66
00:04:45,800 --> 00:04:47,090
classes attributes.

67
00:04:47,780 --> 00:04:48,320
Cool.

68
00:04:48,650 --> 00:04:53,300
Now, also, we can add extra functions and attributes into the head master class.

69
00:04:53,900 --> 00:04:58,850
For example, we can define a method named change class class.

70
00:04:59,060 --> 00:04:59,840
Headmaster.

71
00:05:02,630 --> 00:05:03,140
Teacher.

72
00:05:04,350 --> 00:05:06,150
Death, change class.

73
00:05:07,300 --> 00:05:08,980
SELV, new class.

74
00:05:11,140 --> 00:05:13,300
Print changing class.

75
00:05:16,180 --> 00:05:17,860
Self taught classes.

76
00:05:19,050 --> 00:05:21,030
Equals new class.

77
00:05:24,050 --> 00:05:25,300
And now let's test it.

78
00:05:26,690 --> 00:05:28,940
Create a new object named headmaster to.

79
00:05:36,340 --> 00:05:36,880
Jack?

80
00:05:39,440 --> 00:05:41,180
Though, headmaster.

81
00:05:42,550 --> 00:05:43,170
None.

82
00:05:43,760 --> 00:05:44,350
Male.

83
00:05:46,130 --> 00:05:47,480
Two February.

84
00:05:49,440 --> 00:05:51,120
1979.

85
00:05:52,610 --> 00:05:54,200
Let's see the info.

86
00:05:55,250 --> 00:05:56,060
Headmaster.

87
00:05:59,470 --> 00:06:00,910
Don't show info.

88
00:06:03,040 --> 00:06:04,810
Good, so now we can use the new method.

89
00:06:09,000 --> 00:06:13,050
Headmaster to that change class.

90
00:06:13,990 --> 00:06:14,530
Tenth.

91
00:06:19,350 --> 00:06:22,200
Check the info again, headmaster to.

92
00:06:24,040 --> 00:06:25,450
Don't show info.

93
00:06:27,970 --> 00:06:28,630
And that's it.

94
00:06:28,810 --> 00:06:29,710
You see how that works.

95
00:06:30,280 --> 00:06:31,030
Very cool.

96
00:06:31,840 --> 00:06:35,740
So in this lesson, we learned the inheritance concept in Python.

97
00:06:36,490 --> 00:06:38,190
So we're going to put it to good use later.

98
00:06:38,200 --> 00:06:39,580
So stay tuned.

99
00:06:39,730 --> 00:06:40,000
See you.

100
00:06:40,000 --> 00:06:40,600
Next lesson.

101
00:06:41,170 --> 00:06:41,950
Have a nice day.
