#49 Python Tutorial for Beginners | Class and Object

Поділитися
Вставка
  • Опубліковано 14 сер 2018
  • Check out our courses:
    Spring and Microservices Weekend Live Batch : bit.ly/spring-live-weekend
    Coupon: TELUSKO10 (10% Discount)
    Master Java Spring Development : bit.ly/java-spring-cloud
    For More Queries WhatsApp or Call on : +919008963671
    website : courses.telusko.com/
    Instagram : / navinreddyofficial
    Linkedin : / navinreddy20
    TELUSKO Android App : bit.ly/TeluskoApp
    Discord : / discord
    In this lecture we will learn:
    - Class and object in Python
    - How are a class and an object created?
    - Syntax for creating a class
    - Syntax for creating an object
    - How to call a method through an object?
    - What is the type of an object?
    #1
    - Class is a blueprint to create objects.
    - Integer, Float, String, etc., are in-built types in Python.
    - To create our type like a computer, we have to create our own class for it.
    - To use the type that you have created, you need to define a class for it.
    - A class can be defined by using the class keyword and every class must have a name to it.
    The syntax for creating a class:-
    class class_name:
    methods():
    statements
    variables
    - A class consists of two things:
    1. Attributes - Variables
    2. Behaviour - Methods (Functions)
    #2
    - An object of a class can be defined by a variable and assigned its value with the type of the class.
    - A class can have multiple objects.
    Syntax of creating an object:-
    object variable = class_name()
    #3
    - type() return the type of a value that is present inside the variable.
    - If we will return the type of an object, then it will print the class name. It means an object belongs to a type of particular class.
    - String, integer, etc are also object that belongs to some in-build class like str and int respectively.
    #4
    - We can call any method from a class.
    - The behaviour of every object will be different from each other so need to define for which object, you are calling a method.
    - So, we need to pass an object in it as a parameter at the time of calling a method.
    The syntax for calling a method:-
    class_name.method_name(object variable)
    - We pass an object to a method as an argument that will go into the self.
    - Self is the object that you are passing in a method.
    - We can also call a method in another way:
    object_variable.method_name()
    Python Tutorial to learn Python programming with examples
    Complete Python Tutorial for Beginners Playlist : • #1 Python Tutorial for...
    Python Tutorial in Hindi : • #1 Python Tutorial | I...
    Github :- github.com/navinreddy20/Python-
    Java and Spring Framework For beginners with Spring Boot : - bit.ly/3LDMj8D
    Java Tutorial for Beginners (2023) :- bit.ly/3yARVbN
    Editing Monitors :
    amzn.to/2RfKWgL
    amzn.to/2Q665JW
    amzn.to/2OUP21a.
    Subscribe to our other channel:
    Navin Reddy : ua-cam.com/channels/xmk.html...
    Telusko Hindi :
    ua-cam.com/channels/itz.html...
    Donation:
    PayPal Id : navinreddy20
    Patreon : navinreddy20
    www.telusko.com/contactus
  • Наука та технологія

КОМЕНТАРІ • 441

  • @davidnjoagwuani8184
    @davidnjoagwuani8184 4 роки тому +163

    Not all heroes wear capes! This video was the "silver bullet" i needed to understand classes in python. Hope to see more videos concerning other aspects of python.

  • @user-yh1kv7qe7t
    @user-yh1kv7qe7t 8 місяців тому +16

    This is beyond excellence! After 24 years, I'm finally understanding how classes actually work.

    • @motivationda2067
      @motivationda2067 3 місяці тому +2

      THEN MY 2 YEARS DOESNT MATTER IT SEEMS LOL

  • @IamNavi7
    @IamNavi7 4 роки тому +22

    BRO, THIS TYPE OF CLARITY I DIDN'T EVEN GET IN MY SCHOOL/COLLEGE TIME...YOU ARE INSANE AT TEACHING.....KEEP IT UP

  • @edwardgregory9219
    @edwardgregory9219 4 роки тому +20

    this is how I understood it and I hope it can help others in their thought process, its a bit long but worth the read.
    · The logic in creating Classes and its objects are similar to how we work with functions.
    · Remember when we create a function, we 1st define it with a keyword, 2nd assign it with arguments, 3rd give the logic/conditions (we know these as statements) 4th return the values and 5th call the function to execute it. In the aforementioned process we have ( : ) colon, which indicates that it’s a function and followed by its appropriate indentations.
    · In Classes we have a similar process of syntax, 1st, we create the class by using the keyword class to indicate it’s a class, 2nd followed by the keyword (the name of the class/design) and again the use of ( : ) to indicate that 3rd, it will follow a METHOD (remember from Tutorial 48, Functions in an Object Oriented Programming are called METHODS), 4th, followed by its logic or the condition/statements of the METHOD, i.e. what is it that the METHOD should do?, 5th, after which we CREATE THE VARIABLE (The object) that will be used as the argument in the METHOD of the CLASS, and 6th lastly CALL the Class’s Method for execution.
    · For example, we are creating a METHOD through CLASS and assigning HUMANS as variables and when each human is CALLED it will step forward and shout, Hello Sir!
    class human(): # Here we have created the CLASS by using the keyword, which is an OBJECT called human
    def shout(self): # Here we have defined its METHOD of which the object HUMAN is going to BEHAVE (function), in this example when called they will say Hello Sir!
    print('Hello Sir!') # The statement, i.e. what the VARIABLES are supposed to do when called upon
    ed=human() # Here we created new VARIABLES and assigned them as HUMAN
    dan=human()
    jon=human()
    human.shout(ed) # Here we are calling the CLASS by using its METHOD to pass the ARGUMENT to trigger the ACTION of saying Hello Sir! In other words we are saying; Hey Human, shout Hello Sir, you Ed
    human.shout(dan)
    human.shout(jon)
    jon.shout() # this is another way (a more common way) of CALLING the CLASS, as you can see we are simply saying - VARIABLE (ed) followed by the METHOD (shout) the ACTION of Hello Sir!
    ed.shout()
    dan.shout()

  • @deanetim979
    @deanetim979 2 роки тому +17

    You have really made the concept of OOP in Python less terrifying to me.
    I used to be afraid of it because I never understood what classes and objects were. Thank you!

  • @mohammadjadallah9813
    @mohammadjadallah9813 2 роки тому +5

    I love your ‘method’ of teaching. You acknowledge how beginners don’t understand how this stuff works. So working your way back and making everything clear was very helpful. Thank you!

  • @aashishmalhotra
    @aashishmalhotra 2 роки тому +27

    What a great teacher he is , makes every concept crystal clear. I hope that you got blessed with UA-cam algorithm so that your channel got recommended to each person who wants to learn coding.

  • @ybpatil575
    @ybpatil575 4 роки тому +52

    Dada, i took interest in learning python just cz of your way of teaching ! ..Mechanical engg. here .
    keep it up !!!

  • @jasonzelin5351
    @jasonzelin5351 Рік тому +8

    Never thought understanding the concept of class and objects would be so quick and easy. Thank you a lot!

  • @bishwadeepchatterjee2348
    @bishwadeepchatterjee2348 4 роки тому +5

    It is rightly said that the best things come for free.
    Navin, you are an excellent teacher, the way you teach is brilliant enough for even a 10 year old kid to learn python.
    Thank you so much.

  • @motivationinstinct
    @motivationinstinct 3 роки тому +8

    This is the best python tutorial I found to be on youtube ! Thank you for the simple explanation and concepts.

  • @adarshtiwari7395
    @adarshtiwari7395 4 роки тому +4

    Hands down the best playlist to learn python. Navin you're doing a commendable job on this channel. All the very best and thank you for the content !

  • @ishankvaish1130
    @ishankvaish1130 2 роки тому +3

    I don't think I have ever seen anybody enjoy teaching as much as he does! Thank you :)

  • @karanb2067
    @karanb2067 3 роки тому +6

    this concept was made so hard in an earlier bootcamp of python I took, Thank you for making it so much clear!

  • @shubhamkothari2709
    @shubhamkothari2709 5 років тому +6

    Just loving the way you teach.You're making it so simple to understand.Thank you so much for all the time you put in for us people.Love ❤Keep up with it 🔥

  • @mideroberts
    @mideroberts 4 роки тому +1

    This video just de-mystified the concepts of "classes". I like how your examples are so relatable; that way I can have proper building blocks in my head. Kudos to you. I am definitley gonna look for more vidoes from you.

  • @skviknesh
    @skviknesh 4 роки тому +61

    Seriously Navin, A big Thank you! First place where I understood class completely

    • @raghav4858
      @raghav4858 4 роки тому

      Hey when I use print(comp1.config())
      My output is:
      i5,16gb,1TB
      None
      Ques:Why did this "None" come

    • @PavanKumar-by8dc
      @PavanKumar-by8dc 4 роки тому

      @@raghav4858 if u use obj reference by calling class methods in print it shows you the none , because it expects the return

    • @aritroshome4443
      @aritroshome4443 4 роки тому +2

      @@raghav4858 print returns void or None as config does not return anything but itself prints a line

    • @rahulra8358
      @rahulra8358 3 роки тому

      Mass class sup

    • @yashsinghal7471
      @yashsinghal7471 3 роки тому +1

      Shi kha..

  • @sumantakumardutta986
    @sumantakumardutta986 3 роки тому +8

    9:01 This is where Python and Java are similar. I love this course as Navin sir compares Python with Java at many instances to make things clear for students like me, who is switching from Java to Python. 😀🎉

    • @prasannakatre4040
      @prasannakatre4040 Рік тому

      Unrelated, but may I please ask why are your switching from Java to Python?

  • @prakharsharma6619
    @prakharsharma6619 3 роки тому +1

    Awesome one! Much intuitively explained in contrast with a number of other places I tried. Went straight in. Looking forward to watching a great explanation again in lecture #50. Thanks Navin!

  • @umeshpandey5226
    @umeshpandey5226 4 роки тому +4

    One of the best oops tutorial on UA-cam plateform...never seen before.....thank you very much to Naveen sir..

  • @kiran-qs5pu
    @kiran-qs5pu 3 роки тому +16

    him: Hey kiran, walk!
    me: *frowns*

  • @S0912S
    @S0912S 3 роки тому +7

    It was a great session. I get easily confused every time I try to understand this concept and this really helped, thank you!

  • @VarunKumar-qd5wl
    @VarunKumar-qd5wl 4 роки тому +83

    Telusko meaning 'Learn' in Telugu..
    Perfectly suited name.

    • @Medsainath
      @Medsainath 3 роки тому +1

      Wow how do come to know bro? I was searching it's meaning for long time.

    • @crickettrendzz5477
      @crickettrendzz5477 3 роки тому +6

      @@Medsainath
      😂 Simple bro
      Our mother tongue is telugu
      🤣🤣🤣

    • @Medsainath
      @Medsainath 3 роки тому +1

      @@crickettrendzz5477 yaa I too know Telugu very well

    • @crickettrendzz5477
      @crickettrendzz5477 3 роки тому +1

      @@Medsainath
      Ooh 😀 you've just joked as you doesn't know that meaning 😂

    • @Medsainath
      @Medsainath 3 роки тому

      @@crickettrendzz5477 ha ha 😂 by the way wr do u live and which class r u

  • @khaben6986
    @khaben6986 5 років тому +7

    ur series are amazing they help to have a fast understanding of python ur incredible thank u ^^

  • @sanyogpatial1819
    @sanyogpatial1819 Місяць тому

    I have been banging my head for 3 days to wrap my head around the concept of class, method ,objects their interplay in OOP after countless google search and you tube search this video saved a day for me by explaining each concept step by step in clear and concise way. Thanks a lot and more power to you. I firmly believe that “ there are no difficult concepts but only difficult explanations”.

  • @abufarhaz2306
    @abufarhaz2306 2 роки тому

    Bro, I was confused about python class for so long. It took 10 minutes probably for you to make it clear. You are great and so efficient.

  • @bhavana333
    @bhavana333 4 роки тому +2

    Awesome explanation. I am learning oops concepts first time and this kind of base i expected. Thanks so much . Really helpful.

  • @tingli8300
    @tingli8300 5 років тому

    U r so awesome to sort it out my problems,thank you so much!!!!!!! For a fresh programmer, you r the best ever youtuber and educator for sharing the knowledge !!!!!!

  • @sandipadhikari9494
    @sandipadhikari9494 4 роки тому

    Your presentation skills are really good.The way you teach the basic concepts of any topic is unique.

  • @pranav8701
    @pranav8701 4 роки тому +1

    I visited first time this channel. Teaching skill ='WOW'.

  • @krishnarout9176
    @krishnarout9176 4 роки тому +4

    Thankyou sir, too teach for free. You are really a Great person With Great personality.

  • @rohit-2427
    @rohit-2427 3 роки тому

    Lucky to find this channel I've been searching randomly for python tutorials and I found this channel and gone through the videos and you know what's next😎😎 addicted to his teaching 😉

  • @nileshthombre6253
    @nileshthombre6253 5 років тому +1

    I'm new in this industry, after watching at least 4-5 times. I able to understand Thanks :)

  • @rayan4203
    @rayan4203 4 роки тому

    Hi, Navin Reddy, you did wonderful work. i am really thankful to you for providing us a Python learning information.

  • @smalirizvi8026
    @smalirizvi8026 3 роки тому

    Navin bhai
    I LOVE YOU!! May God bless you.
    You are a gem in the world of educating and explaining

  • @MUNA116ful
    @MUNA116ful 3 роки тому

    Your way of explaining is just AWESOME. Thank you so much.

  • @Dhananjoybhatta123
    @Dhananjoybhatta123 4 роки тому

    I heard about the "class" thing in programming. But I got to understand when I watched your video.Thank you so much. By the way sir, I'm have completed my 12th only, couldn't complete my grad. But I was always interested in coding. After watching your video I am willing to work on a real-time project. Thanks for your way of teaching. I want to learn more from you.

  • @ebabu7485
    @ebabu7485 4 роки тому

    this is awesome navin the way you are explaning ....love the way you teach with practicals ....gone through so many websites ..but this is all time best one

  • @lynx0808
    @lynx0808 2 роки тому

    I have watched so many videos on classes and this is the one i needed! Thank you

  • @suryaganeshpindiprolu472
    @suryaganeshpindiprolu472 3 роки тому

    The you explained is just amazing. I wouldn't be able to understand this concept without you🖤

  • @MovieBinge007
    @MovieBinge007 4 роки тому +1

    Your videos are my new addiction Navin Sir!!!!

  • @pankhudiseth
    @pankhudiseth 4 роки тому +2

    Love your unique examples! Keep going!

  • @johng5295
    @johng5295 3 роки тому

    Thanks in a million. If you can explain like this to a child, it means you have mastered it. A+

  • @rotrose7531
    @rotrose7531 5 років тому +4

    Sir, please come up with another series because your explanation is excellent and that helps accelerating our understanding, do not know what to do once 62 lessons are done.

  • @siddharthmodi5908
    @siddharthmodi5908 3 роки тому

    Thank you sir for providing best python classes , your teaching skills are beyond perfect

  • @deepanshudutta4443
    @deepanshudutta4443 3 роки тому

    Sir,your teaching style is just amazing and cool..I understood all the things very well.....

  • @KoreaRwkz
    @KoreaRwkz 4 роки тому +7

    4:07
    I believe the __main__ lets us know that the computer class is defined in the main file. If it were defined in another file, it would show the corresponding module name.

    • @sreekarg8648
      @sreekarg8648 3 роки тому

      Does that mean one can have classes inside classes?

  • @user-gd5pq2pi2f
    @user-gd5pq2pi2f 5 місяців тому

    Thanks a lot Mr. Naveen Reddy. Finally, I understood the concept of classes and object.

  • @patrickcordero6673
    @patrickcordero6673 3 роки тому

    i love your analogy. It makes the concept way easier.

  • @maheswarisadhu5102
    @maheswarisadhu5102 5 років тому

    ur teaching skills are excellent sir giving knowledge by correct way.thank u so much sir

  • @aayyaa1188
    @aayyaa1188 3 роки тому

    Thank you soooooo much.
    Love your videos. It's always so clear and really explaining the core concepts.

  • @thedestructor3505
    @thedestructor3505 3 роки тому

    Way easier to understand than any other online platforms ❤️❤️

  • @bangbinbash
    @bangbinbash 9 місяців тому

    Wow stumbled upon this video and it's easily the best explanation of class/object I've ever seen 😮

  • @lakshmisravyak5517
    @lakshmisravyak5517 3 роки тому

    oh my god you are awesome sir!!!!you made me to understand the concept which i am struggling to understand for a week ,tq for the effort you put in

  • @anuj702
    @anuj702 4 роки тому

    wow I have seen so many online videos but u r the best one to explain

  • @ankushashi3736
    @ankushashi3736 5 років тому

    Grate grate grate explanation sir..I know this concept before ..but I m always exited for your video ..you always explain concept in very interesting and simple way ..your explanation give more clearly to my knowledge..grate work sir..🙏🙏🙏

  • @gauravkulmethe3628
    @gauravkulmethe3628 3 роки тому

    You are awesome sir....I didn't get the concept of oop in python earlier but watching your tutorial give me brief knowledge about it...🔥🔥🔥

  • @pavan5208
    @pavan5208 2 роки тому

    best tutorial I came across to understand about Classes in python. Thank you!

  • @karan0611
    @karan0611 Рік тому

    I had seen many videos but your video made me understand very well Thank you a lot!

  • @gowreswarreddykona2083
    @gowreswarreddykona2083 5 років тому

    Very nice way of explaining things I like very much want much more in single vedio with general programs
    Love u the way how u teach

  • @dannyezechukwu1175
    @dannyezechukwu1175 Рік тому

    Just earned a new subscriber! Thank you Navin!

  • @debolinamajumdar
    @debolinamajumdar 4 роки тому +1

    I cannot thank you enough for these sessions. So so amazingly explained .

  • @BrighterWay
    @BrighterWay 4 роки тому

    I have learn Oop before but I never understand that as you teach me. One Of The best Teacher I have ever mate, Just Awesome Video👍👍.You are Doing Great

  • @Runningbowels
    @Runningbowels 5 років тому +2

    Thank you so much for the explaining this so cleary!!!

  • @sachinr6042
    @sachinr6042 5 років тому +12

    Your video editing further improves your explanation.

  • @rishikeshsawant
    @rishikeshsawant 2 роки тому

    If you have come this far both you and navin(sir) are legend.

  • @omaral-bakri2656
    @omaral-bakri2656 5 років тому +3

    You mad coding looks sooo much easier. Thanks a lot !

  • @iammiban
    @iammiban 2 роки тому

    Thankyou So much for making learning so easy and bite-sized

  • @debakamalhazarika7097
    @debakamalhazarika7097 3 роки тому

    Sir , your way of approaching is good. I learned python upto an intermediate level..but wanted to go further and here your videos are helping me a lot. Its very systematic with reasoning, "why" , "how" and "when" to use all these. Just can you elaborate about "class" with some definitions .Thank You

  • @el0150
    @el0150 5 років тому +73

    3:51 switch on the subtitles, you won't regret it

  • @anuragray6924
    @anuragray6924 Рік тому

    You solved a big question for me. Thank you so much.

  • @oborraacademy5613
    @oborraacademy5613 3 роки тому

    I had many doubts in class but your explanation was so helpful and I liked it a lot. Thank UUUUU😀😃😃

  • @bartekkowalski8393
    @bartekkowalski8393 3 роки тому

    I love your teaching style. Thanks from Canada

  • @yashrastogi3726
    @yashrastogi3726 5 років тому

    Your videos are awesome. I didn't know the first method . Thanks

  • @ashishtripathii399
    @ashishtripathii399 4 роки тому

    really sir outstanding ........and the way u teaching is quite amazing

  • @vysakhkailas940
    @vysakhkailas940 4 роки тому

    Very well explained !! Thank you for this 1.

  • @kmeenu
    @kmeenu 4 роки тому

    Thank you so much for making it so easy to understand Sir!

  • @rajibguha6960
    @rajibguha6960 5 років тому +1

    again style of teaching fantastic..

  • @sufiyanmogal1527
    @sufiyanmogal1527 2 роки тому

    Thank you sir the class and object topic is hard but u explain these in easyway

  • @danielworkneh3608
    @danielworkneh3608 5 років тому +3

    you are so nice at explaining the idea.
    I wish you were my teacher!!!!!!!!!

  • @joshuabadejo1573
    @joshuabadejo1573 Рік тому

    Thank you sir, always taking your time and teaching in a relatable manner.

  • @jaswantdn7
    @jaswantdn7 3 роки тому

    I have been looking for a solution to my problem. finally, I got one. Thank you, sir.

  • @lokeshmadiga6215
    @lokeshmadiga6215 4 роки тому

    Great i am new for OOPS l think i will learn lot more from your videos

  • @Mike-og4wc
    @Mike-og4wc 2 роки тому

    Крутой ты чувак, Навин. Спасибо за видео :)

  • @atulayagupta785
    @atulayagupta785 3 роки тому

    Very clear explanation for beginners, Thanks

  • @androygaminghk1197
    @androygaminghk1197 4 роки тому

    Really tq sir....the examples you use to make us understand are awesome...tq

  • @sanketjori1981
    @sanketjori1981 2 роки тому

    okay
    so finally i am cleared what classes and objects actually
    thank you so much sir

  • @AnujKumar-ie7rn
    @AnujKumar-ie7rn 4 роки тому

    'Good habits and deep knowledge', thanks sir

  • @robinx0471
    @robinx0471 Рік тому

    a good explanation from other ,thnk for your valuable information.

  • @NeerajKumar-qj6nc
    @NeerajKumar-qj6nc 3 роки тому

    Great teaching concept sir. everything is cleared very easily.

  • @karabgut
    @karabgut 3 роки тому +2

    whenever I watch ur videos my mood is goin up up up :D

  • @artabra1019
    @artabra1019 4 роки тому

    this is really clear tutorial wow im amaze thank you so much

  • @itsrico6394
    @itsrico6394 3 роки тому

    Mehn you are the best, your explanations are clear and one is able to understand.......thank you

  • @akashpoudel571
    @akashpoudel571 5 років тому

    sir as a first timmer its my boon to learn frm u........ u r a cool explainer.....

  • @prachihiware9390
    @prachihiware9390 4 роки тому

    Concepts Got Cleared so well..

  • @sindhubasavanna1927
    @sindhubasavanna1927 5 років тому

    nice explanation. you try to cover all possible ways in each topic.

  • @worldofcharisma3723
    @worldofcharisma3723 8 місяців тому +1

    Wow! So awesome.... You are truely a day saver.....

  • @vikhyatbansal
    @vikhyatbansal 4 роки тому +1

    Thankyou so much sir,
    Big fan❣️❣️

  • @gokulp4788
    @gokulp4788 4 роки тому

    Thank you so much bro....
    Very simple narration....

  • @yogeshraja1481
    @yogeshraja1481 4 роки тому

    guys, mostly no one can understand easily. after watching at the end of the video, again re-play this video, then can understand.
    navin jii..awesome...