Free Python tutorial for beginners-Python Programming-How to use __str__ method in Python class def

Free Python tutorial for beginners-Python Programming-How to use __str__ method in Python class def


Free Python tutorial for beginners-Python Programming-How to use __str__ method in Python class def

Free Python tutorial for beginners-Python Programming-How to use str init

Subscribe Here -https://www.youtube.com/@KeeshtuTechn

#python#pythonprogramming #pythontutorial #pythonforbeginners #pythonclass #youtubechannel #pythoninstallationcomplete #pythonhowtoinstall #pythoninstall #pythondownload #pythontutorialfree #pythonyoutube #pythonenglish #pythonenglish #pythonexecvseval #pythonexec()vseval() #pythonexec() #pythoneval() #youtubeviews #pythondef #pythondef() #pythonfunctions #pythonbreak #pythoncontinue #pythonpass #pythonzip #pythonunzip #pythonprintescapecharacter #pythonrepr() #pythonr
Please Captions on - Python in English, Python in Tamil, Python in Telugu, Python in Malayalam, Python in Chinese, Python in Japanese, Python in German, Python in Hindi, Python in French, Python full course for beginners

welcome to technology platform so today we are going to see like how to use Str method in our class so let’s see let me open idle

so now earlier what we see like class my class colon enter Def and then we can say like initialize init initialize I’ll say like first self it is a mandatory and then course name I will say like this and comma chapters as well so then colon enter and then I will assign self dot course name equal to course name self dot chapters equal to chapters like that I am assigning after that def I’m returning my function and then using self it is mandatory now enter print of I’m just calling course name hyphen

Plus self Dot course name you should call like this only you should not call only course name it should not return so then Plus

and chapters

and then I will say like self Dot chapters so this is what we have already seen now once you are going to call it like create one variable class call my class equal to my class this is what you’re just going to call here and then passing like python

and then 10 chapters like that you’re calling it after that finally printing call my class dot function this function you want to call it here Open Bracket close bracket then close so it is printing course name is Python and chapters it’s like hyphen 10. so the none we have already seen like it should return something written for example if we call it here I should say like return

all completed like that I can say that and then if you call this

oh sorry

enter and then you can call this

now it is returning some values so this is what normally we have seen it right now underscore Str so why we are going to use it let’s see now you’re just using the same class

and instead of my function you are going to use it Str see this this one you already Define it def off instead of my function you are going to write it like underscore Str and then self and then close enter then instead of print right you have to use it like written return I can say like so you already used formatting function if so double quotes you have to use this course name

and then this bracket and then self course name then close bracket again and

chapters and Open Bracket self dot chapters

now see this so instead of my function you have used it Str and then you use written why we are using FS like we have to use it this Square flower packet because of that formatting the string we are using this F now enter enter now same thing you are going to pass it

but instead of your calling my function right you can directly call the class see this my class close bracket so not my class this one this object and then enter see here you just know the difference here we used my function self and then we are calling my class dot my function but here we used Str the same thing but here we used to return and instead of call my class dot my function we used this underscore HDR so we are not using anything simply we are calling this class directly and it is returning the value so this is what uh the explanation of Str so see you in the next class thank you bye


Content

0.6 -> welcome to technology platform so  today we are going to see like how  
4.98 -> to use Str method in our class  so let's see let me open idle
17.7 -> so now earlier what we see like class my  class colon enter Def and then we can say like  
28.74 -> initialize init initialize I'll say  like first self it is a mandatory and  
36.18 -> then course name I will say like  this and comma chapters as well  
40.86 -> so then colon enter and then I will assign  self dot course name equal to course name  
50.64 -> self dot chapters equal to chapters like that I am  assigning after that def I'm returning my function  
63.6 -> and then using self it is mandatory now enter  print of I'm just calling course name hyphen
78.54 -> Plus self Dot course name you  should call like this only you  
85.32 -> should not call only course name  it should not return so then Plus
94.5 -> and chapters
98.82 -> and then I will say like self Dot chapters so  this is what we have already seen now once you  
105.66 -> are going to call it like create  one variable class call my class  
114.12 -> equal to my class this is what you're just  going to call here and then passing like python
126.48 -> and then 10 chapters like that you're  calling it after that finally printing  
133.98 -> call my class dot function this function you  want to call it here Open Bracket close bracket  
143.76 -> then close so it is printing course name  is Python and chapters it's like hyphen 10.  
151.8 -> so the none we have already seen like it  should return something written for example  
157.74 -> if we call it here I should say like return
165.3 -> all completed like that I can say  that and then if you call this
173.7 -> oh sorry
176.76 -> enter and then you can call this
181.38 -> now it is returning some values so this is what  normally we have seen it right now underscore  
190.14 -> Str so why we are going to use it let's  see now you're just using the same class
202.74 -> and instead of my function you  are going to use it Str see this  
209.28 -> this one you already Define it  def off instead of my function  
216.6 -> you are going to write it like underscore  Str and then self and then close  
229.38 -> enter then instead of print right you have  to use it like written return I can say like  
240.12 -> so you already used formatting function if so  double quotes you have to use this course name
255.12 -> and then this bracket and then self  course name then close bracket again and
269.1 -> chapters and Open Bracket self dot chapters
279.84 -> now see this so instead of my function you have  used it Str and then you use written why we are  
290.04 -> using FS like we have to use it this Square  flower packet because of that formatting the  
295.32 -> string we are using this F now enter enter  now same thing you are going to pass it
307.62 -> but instead of your calling my function right  you can directly call the class see this  
315 -> my class close bracket so not my class this  one this object and then enter see here you  
327.66 -> just know the difference here we used  my function self and then we are calling  
334.08 -> my class dot my function but here we used Str  the same thing but here we used to return and  
341.94 -> instead of call my class dot my function we used  this underscore HDR so we are not using anything  
348.42 -> simply we are calling this class directly and  it is returning the value so this is what uh  
356.76 -> the explanation of Str so see you  in the next class thank you bye

Source: https://www.youtube.com/watch?v=DcOKLzJ9LJg