I Was watching telusko channel to learn python but abstract i could not understand there, so searched other video , i understood very clearly with this video, THANKS A LOT DUDE, inshah allah i like to go thru ur videos inshah allah. thank u .
from abc import ABC,abstractmethod class Animal(ABC): @abstractmethod def eat(self): print("This is eating something") class Rabbit(Animal): def eat(self): print("This is eating grass")
from abc import ABC, abstractmethod class Vehicle(ABC): @abstractmethod def start_engine(self): print("Engine started")
class Bike(Vehicle): def start_engine(self): print("Bike engine started.") wheels = 2 ktm = Bike() ktm.start_engine() I think this is a good example for abstractmethod.
from abc import ABC, abstractmethod class Shape(ABC): @abstractmethod def printarea(self): return 0 s1-Shape()#this line throws an error as per my understanding we are not allowed to instantiate a metclass? Am i correct?
Yes, we can't instantiate an abstract class because its an incomplete class without any proper functionality and output for the abstract methods. these abstract methods are just meant for other child classes to be implemented. Thus we need a concrete subclass to get instantiated with the help of an object. Hope it helped :)
ha ho ja rha brother maine krke dekha niche ka code dekho # date 07 july 2022 class Quadrilatera: type="four sides" angle="four angles" def __init__(self,lenth1,lenth2,breadth1,breadth2,diagonal,perpendicular1,perpendicular2) : self.lenth1=lenth1 self.lenth2=lenth2 self.breadth1=breadth1 self.breadth2=breadth2 self.diagonal=diagonal self.perpendicular1=perpendicular1 self.perpendicular2=perpendicular2 print("Area of quadrilateral = (½) * diagonal length * sum of the length of the perpendiculars drawn from the remaining two vertices.") def area (self): self.area=(1/2)*{self.diagonal1}*{self.perpendicular1+self.perpendicular2} class Rectangle: type="quadrilateral" sides=4 angles=4 def __init__(self,lenth1,lenth2): self.lenth1=lenth1 self.lenth2=lenth2 def area (self): self.area=self.lenth1*self.lenth2 a=Quadrilatera(21,32,65,4,56,567,67) b=Quadrilatera.Rectangle(23,45) print(a.lenth1) print(b.lenth1)
@@creaturetrendy ha ho ja rha brother maine krke dekha niche ka code dekho # date 07 july 2022 class Quadrilatera: type="four sides" angle="four angles" def __init__(self,lenth1,lenth2,breadth1,breadth2,diagonal,perpendicular1,perpendicular2) : self.lenth1=lenth1 self.lenth2=lenth2 self.breadth1=breadth1 self.breadth2=breadth2 self.diagonal=diagonal self.perpendicular1=perpendicular1 self.perpendicular2=perpendicular2 print("Area of quadrilateral = (½) * diagonal length * sum of the length of the perpendiculars drawn from the remaining two vertices.") def area (self): self.area=(1/2)*{self.diagonal1}*{self.perpendicular1+self.perpendicular2} class Rectangle: type="quadrilateral" sides=4 angles=4 def __init__(self,lenth1,lenth2): self.lenth1=lenth1 self.lenth2=lenth2 def area (self): self.area=self.lenth1*self.lenth2 a=Quadrilatera(21,32,65,4,56,567,67) b=Quadrilatera.Rectangle(23,45) print(a.lenth1) print(b.lenth1)
to hide internal details in real life it is like " AAM KHAO GUTLIYA MT GINO" so only method name is provided in parent class and implementation in child class.
@abstractmethod is decorator . And in short it will not allow us to execute class which are inherited from abstract class unless all abstract class method and properties are overridden .
# -*- coding: utf-8 -*- """ Created on Wed Jan 4 09:43:46 2023 @author: Dell """ from abc import ABCMeta,abstractmethod class Hazur(metaclass=ABCMeta): @abstractmethod def love(self): return 0
class babaji(Hazur):
def __init__(self): return print("my name is:") def love(self): return print("I love you 3000 times")
class gtm(Hazur): pass def love(self): return print("I love you 9000 times")
gt=babaji() gt.love() g=gtm() g.love() sir I have doubt here when I give pass in gtm class then why is it giving correct result instant of error because pass is give here so compiler should move from here but it read till last line why
This guy is born to help people. God bless you. Great valuable videos. Learning a lot from you bro. Thank you..
Everyone: How to resolve this error?
Harry Bhai: How to get this error 😆😆
haha
Abc metaclass is to as a checker, who Insures that certain methods must be implemented by The inheriting class
I Was watching telusko channel to learn python but abstract i could not understand there, so searched other video , i understood very clearly with this video, THANKS A LOT DUDE, inshah allah i like to go thru ur videos inshah allah. thank u .
same here
@@janaksiddhpura7704 😊👍
Same here
Telusko is also good for learning Python but harry is the best
from abc import ABC,abstractmethod
class Animal(ABC):
@abstractmethod
def eat(self):
print("This is eating something")
class Rabbit(Animal):
def eat(self):
print("This is eating grass")
obj=Rabbit()
obj.eat()
0:21 BC matlab base class, Kuchh aur mat samajh baithiyega 😁😁😂😂
Congratulations for 3M Subscribers🎉
1st watched this video he has 70K. again now watching it is 3 Millions.
Edward elric
thank you sir aapki wajah se aaj me apni life ki first programming langguage sikh paya hu thank you so much sir
3:31 too good to make errors 😂😂
from abc import ABC, abstractmethod
class Vehicle(ABC):
@abstractmethod
def start_engine(self):
print("Engine started")
class Bike(Vehicle):
def start_engine(self):
print("Bike engine started.")
wheels = 2
ktm = Bike()
ktm.start_engine()
I think this is a good example for abstractmethod.
Excellent coder in you tube
best teachers💗💗💗
i can do it. i will be a good programmer, thank you harry bhai.
i was thinking till this video that "harry bhai bahut sidhe hai vo kahan ye sab bolte honege" 0:19 LOL
same mujhe bhi laga tha
iit ke bande itne itne bhi sidhe nhi hote
god bless you!
bhai, itna simplified kiya abstract class concept ko. Thanks
Thank you Bhai
kuch aur mat samaj baithiega ! 😂
samjh baithe
😂😁
Matlab?
@@PawanKumar-ol5sl birth certificate
Thanks, nice explanation
BC matlab side of a Triangle ABC :)
#day68
Thanks man you made it easy
When harry bhai write his own book of Python Programing ☺
Very nice! Book definitions are super confusing...
Thank you sir
I am sure, this video will be great helpful obviously. I.A.Siddiqui
Badhiya harry bhai.....thoda pace jyada ho gya video ka😅.....anyways great
Best
Love you bro 🤗🤗
Bhai is on form aaj ke video mein
Thaks sir
Thanks a lot
Y return(0) in metaclass
Because metaclass is to ensure that all child classes must have the 'printarea' function, you must return 0 to make it an empty function.
Please use dark modes
from abc import ABCMeta,abstractmethod
class geometry(metaclass=ABCMeta):
@abstractmethod
def area_s(self):
return 0
class Square(geometry):
Sides="4"
def __init__(self,side):
self.side=side
def area_s(self):
return f"Area is {self.side*self.side}"
shapes_s=Square(12)
print(shapes_s.area_s())
ramu=geometry()
print(ramu.area_s())
Itne dhama dham vdo araha hai...kafi sara dekhna pending hai.....but feeling good, I'll finish all these by this Sunday
Bro what is your position today
Means how many languages you learn or doing some job?
Superb bro
Which book do you use for these tutorial?
Please
he is himself a programmer why will he use a book?
but if you want then you can search and buy a book
A Little slow in pace could be helpfull
You can Reduce the speed by clicking on settings(The one on the bottom-left of the screen)-->Playback speed
@@arjunmaindarkar106 That's probably not what he meant. But lol😂
from abc import ABC, abstractmethod
class Shape(ABC):
@abstractmethod
def printarea(self):
return 0
s1-Shape()#this line throws an error
as per my understanding we are not allowed to instantiate a metclass?
Am i correct?
Yes, we can't instantiate an abstract class because its an incomplete class without any proper functionality and output for the abstract methods. these abstract methods are just meant for other child classes to be implemented. Thus we need a concrete subclass to get instantiated with the help of an object. Hope it helped :)
@@harshnegi5811 we we create an object like s1 = Shape you can access the abstract mehtods
Nice bro
Thanku sir
Sir, Can we create more than one abstract class ..
You should try experimenting such queries yourself.
Yes
harry bhai ye class ko jb object bnate h tb class name ko function type kyun likhte h
for example rect1 = Rectangle()
kuchh nhi hua vro
wo harry ki explaination dekh li ab
bas jindagi me kuchh aur nhi chahiye
How can be a Class Not an Abstract Class without implementing any abstract method from parent class?
sir, can we create a class inside a class??
I mean what is inner class??
@@indiankidscoder8190 I think you can't do it. Becoz this is disobeying the inheritance.
ha ho ja rha brother maine krke dekha niche ka code dekho
# date 07 july 2022
class Quadrilatera:
type="four sides"
angle="four angles"
def __init__(self,lenth1,lenth2,breadth1,breadth2,diagonal,perpendicular1,perpendicular2) :
self.lenth1=lenth1
self.lenth2=lenth2
self.breadth1=breadth1
self.breadth2=breadth2
self.diagonal=diagonal
self.perpendicular1=perpendicular1
self.perpendicular2=perpendicular2
print("Area of quadrilateral = (½) * diagonal length * sum of the length of the perpendiculars drawn from the remaining two vertices.")
def area (self):
self.area=(1/2)*{self.diagonal1}*{self.perpendicular1+self.perpendicular2}
class Rectangle:
type="quadrilateral"
sides=4
angles=4
def __init__(self,lenth1,lenth2):
self.lenth1=lenth1
self.lenth2=lenth2
def area (self):
self.area=self.lenth1*self.lenth2
a=Quadrilatera(21,32,65,4,56,567,67)
b=Quadrilatera.Rectangle(23,45)
print(a.lenth1)
print(b.lenth1)
@@creaturetrendy
ha ho ja rha brother maine krke dekha niche ka code dekho
# date 07 july 2022
class Quadrilatera:
type="four sides"
angle="four angles"
def __init__(self,lenth1,lenth2,breadth1,breadth2,diagonal,perpendicular1,perpendicular2) :
self.lenth1=lenth1
self.lenth2=lenth2
self.breadth1=breadth1
self.breadth2=breadth2
self.diagonal=diagonal
self.perpendicular1=perpendicular1
self.perpendicular2=perpendicular2
print("Area of quadrilateral = (½) * diagonal length * sum of the length of the perpendiculars drawn from the remaining two vertices.")
def area (self):
self.area=(1/2)*{self.diagonal1}*{self.perpendicular1+self.perpendicular2}
class Rectangle:
type="quadrilateral"
sides=4
angles=4
def __init__(self,lenth1,lenth2):
self.lenth1=lenth1
self.lenth2=lenth2
def area (self):
self.area=self.lenth1*self.lenth2
a=Quadrilatera(21,32,65,4,56,567,67)
b=Quadrilatera.Rectangle(23,45)
print(a.lenth1)
print(b.lenth1)
Your teach well but sometime I feel that you go very fast.
when bug becomes feature
0:19 lol
I am using the 3.9 version of python is it ok
anyone also who enjoying the this playlist at this in these days
Bhai... Yaar please batao vo return 0 kyu liya hai....
Print area mai....
🤕🤕
harry bhaiya init function vs code me kiu kam nehi kar raha hai ....please blo app kuch
Bhai django per series banao
what is the practical use of these abstract classes & methods?
to hide internal details in real life it is like " AAM KHAO GUTLIYA MT GINO" so only method name is provided in parent class and implementation in child class.
only 1100 people are watching tut. seriously
Bhai Harry lekin Abstract class ki zaroorat kyu padti hai ye to bata do, implement to ho hi jayga
Woww
@CodeWithHarry module not found error : no module named 'abstractmethod' plz help me
import it properly
maybe u have kept file name as abstractmethod or any other module name
Ye sab to thik hae lekin @property kya hota hae
what does @abstractclassmethod actually does? didnt really get that, can anyone help me please.
@abstractmethod is decorator . And in short it will not allow us to execute class which are inherited from abstract class unless all abstract class method and properties are overridden .
bhai plzz stock market ki algos banane ki series shuru kr do plzzz
At least tell the use of abstract class and what is basic concept....
All videos upto this point are good but this one is not that much effective
btaya to hai yrrr video ke andr
❤️
Kuch aur mt samajh lena at 0:20
Hahaha kch aur mat smjh bethiyega 🤣
I'm First
Kuch aur mat samaj bhetiyega
🤣🤣
Ham bahut sidhe bache hai
mai bhi
BC = Base Class
galat mat samjho
Are bhai tumhare bolne ke baad yaad aya. BC ka double mean.
abstract backchod class, hahaha
Ratta
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 4 09:43:46 2023
@author: Dell
"""
from abc import ABCMeta,abstractmethod
class Hazur(metaclass=ABCMeta):
@abstractmethod
def love(self):
return 0
class babaji(Hazur):
def __init__(self):
return print("my name is:")
def love(self):
return print("I love you 3000 times")
class gtm(Hazur):
pass
def love(self):
return print("I love you 9000 times")
gt=babaji()
gt.love()
g=gtm()
g.love()
sir I have doubt here when I give pass in gtm class then why is it giving correct result instant of error because pass is give here so compiler should move from here but it read till last line why