filmov
tv
Python super function 🦸
![preview_player](https://i.ytimg.com/vi/MBbVq_FIYDA/maxresdefault.jpg)
Показать описание
python super function tutorial example explained
#python #super #super()
# super() = Function used to give access to the methods of a parent class.
# Returns a temporary object of a parent class when used
class Rectangle:
def __init__(self, length, width):
class Square(Rectangle):
def __init__(self, length, width):
super().__init__(length,width)
def area(self):
class Cube(Rectangle):
def __init__(self, length, width, height):
super().__init__(length,width)
def volume(self):
square = Square(3, 3)
cube = Cube(3, 3, 3)
Bro Code merch store 👟 :
===========================================================
===========================================================
music credits 🎼 :
===========================================================
Creative Commons — Attribution-ShareAlike 3.0 Unported— CC BY-SA 3.0
===========================================================
#python #super #super()
# super() = Function used to give access to the methods of a parent class.
# Returns a temporary object of a parent class when used
class Rectangle:
def __init__(self, length, width):
class Square(Rectangle):
def __init__(self, length, width):
super().__init__(length,width)
def area(self):
class Cube(Rectangle):
def __init__(self, length, width, height):
super().__init__(length,width)
def volume(self):
square = Square(3, 3)
cube = Cube(3, 3, 3)
Bro Code merch store 👟 :
===========================================================
===========================================================
music credits 🎼 :
===========================================================
Creative Commons — Attribution-ShareAlike 3.0 Unported— CC BY-SA 3.0
===========================================================
Комментарии