1 00:00:07,910 --> 00:00:08,930 Hi everybody. 2 00:00:08,930 --> 00:00:10,800 Welcome back. 3 00:00:10,820 --> 00:00:19,170 In this video we will discuss Object Oriented Programming inheritance. 4 00:00:19,180 --> 00:00:29,710 Inheritance allows us to create a general or basic class and reuse and extend it to more and other classes 5 00:00:33,290 --> 00:00:33,860 also. 6 00:00:33,940 --> 00:00:39,580 It allows us to meet our Python code in more efficient 7 00:00:44,990 --> 00:00:45,800 inheritance. 8 00:00:46,130 --> 00:00:54,880 Example let's create superclass and two classes as example fruits class stimulate truth superclass class 9 00:00:56,060 --> 00:01:09,270 banana subclass of the superclass fruit Apple is subclass of subclass fruits let's augment our job it 10 00:01:09,270 --> 00:01:11,830 on notebook at the last. 11 00:01:11,850 --> 00:01:21,280 Could we use in as a constructor video class which is class user data age equals zero name. 12 00:01:21,390 --> 00:01:23,100 Equal none. 13 00:01:23,190 --> 00:01:26,150 Let me underscore any double underscore self. 14 00:01:26,280 --> 00:01:28,080 Name and age. 15 00:01:28,130 --> 00:01:28,990 Salvador name. 16 00:01:29,010 --> 00:01:30,170 Equal name. 17 00:01:30,300 --> 00:01:32,670 That age equal age. 18 00:01:32,670 --> 00:01:38,940 We want to create another class called for numbers. 19 00:01:39,090 --> 00:01:41,610 Class. 20 00:01:42,760 --> 00:01:46,020 Phone number 21 00:01:51,020 --> 00:01:55,340 JF underscore underscore double underscore. 22 00:01:56,880 --> 00:02:12,950 It double underscore parentheses serve and the on then self but num equal num. 23 00:02:13,750 --> 00:02:19,900 We want to use the first class and the second class embattled line. 24 00:02:19,900 --> 00:02:27,450 We can do that without inheritance so we will use inheritance and avoid reputation and code inheritance. 25 00:02:27,460 --> 00:02:29,540 It's easy to understand. 26 00:02:29,680 --> 00:02:37,720 You could think about it as a preventive for reputation and good so class for num when inherit data 27 00:02:37,780 --> 00:02:47,050 from user data when inherit missiles from plus user data so class phone num user data. 28 00:02:48,940 --> 00:02:58,000 Jeff and it self and the NUM we will add data to barometer name and age. 29 00:03:01,200 --> 00:03:14,600 Side num then we will add this line of code Super which is user data not normal underscored in it double 30 00:03:14,600 --> 00:03:15,350 underscore 31 00:03:18,180 --> 00:03:21,560 name and age. 32 00:03:21,570 --> 00:03:30,640 We will assign our users to the second class which inherit missiles of the fittest plus user data user 33 00:03:30,690 --> 00:03:31,980 underscored one equal 34 00:03:34,970 --> 00:03:35,370 phone 35 00:03:38,370 --> 00:03:38,790 num 36 00:03:44,030 --> 00:03:44,570 Sara 37 00:03:47,660 --> 00:03:52,320 forty one two three four five six seven eight nine. 38 00:03:52,430 --> 00:03:55,050 So as a class phone number. 39 00:03:55,420 --> 00:03:56,260 Name and age. 40 00:03:56,260 --> 00:03:59,280 From the first class user data. 41 00:03:59,800 --> 00:04:07,930 Suppose we want to inherit from user data and modifies that inheritance user. 42 00:04:07,930 --> 00:04:11,190 Suppose we have user to equal. 43 00:04:14,320 --> 00:04:18,360 David and 50 44 00:04:24,820 --> 00:04:26,280 wont update that user. 45 00:04:26,550 --> 00:04:30,640 We will use overriding perverted user to 46 00:04:34,640 --> 00:04:36,260 equal for no 47 00:04:40,680 --> 00:04:44,340 David. 48 00:04:45,420 --> 00:04:46,110 Sexy 49 00:04:51,780 --> 00:04:57,330 2 3 4 5 6 7 collect shift and enter. 50 00:04:57,330 --> 00:05:03,870 This will change the age of their user to 51 00:05:06,960 --> 00:05:12,040 that it's we will get 60. 52 00:05:12,100 --> 00:05:18,720 So this is called overriding that's all world class or the parent place. 53 00:05:18,970 --> 00:05:26,080 User 1 we will use 4 numbers class to update their user name. 54 00:05:26,100 --> 00:05:31,240 There is a name and age that understood one. 55 00:05:31,850 --> 00:05:32,310 Equal 56 00:05:35,980 --> 00:05:36,490 Sara 57 00:05:41,130 --> 00:05:41,730 and 13 58 00:05:45,750 --> 00:05:52,040 user underscore one equal phone number 59 00:05:57,700 --> 00:05:58,240 zone 60 00:06:03,250 --> 00:06:03,880 61 00:06:06,760 --> 00:06:12,570 and nine eight seven six five four three two one. 62 00:06:12,570 --> 00:06:17,420 For example shift and enter user 1. 63 00:06:17,670 --> 00:06:26,370 Equal user 1 not name will get John. 64 00:06:26,550 --> 00:06:31,880 So we update the user 1 a name and age and phone number. 65 00:06:31,920 --> 00:06:42,210 Let's try to extract User 1 that each will get 15 also for user 1 66 00:06:45,270 --> 00:06:47,910 not for numbers. 67 00:06:50,760 --> 00:06:57,090 We will get the phone number nine eight seven six five four three two one. 68 00:06:57,510 --> 00:06:58,770 Thank you for watching. 69 00:06:58,770 --> 00:07:01,680 See you next lecture.