Python super function 🦸
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):
self.length = length
self.width = width
class Square(Rectangle):
def __init__(self, length, width):
super().__init__(length,width)
def area(self):
return self.length*self.width
class Cube(Rectangle):
def __init__(self, length, width, height):
super().__init__(length,width)
self.height = height
def volume(self):
return self.length*self.width*self.height
square = Square(3, 3)
cube = Cube(3, 3, 3)
print(square.area())
print(cube.volume())
Bro Code merch store 👟 :
===========================================================
https://teespring.com/stores/bro-code-5
===========================================================
music credits 🎼 :
===========================================================
Up In My Jam (All Of A Sudden) by - Kubbi https://soundcloud.com/kubbi
Creative Commons — Attribution-ShareAlike 3.0 Unported— CC BY-SA 3.0
Free Download / Stream: http://bit.ly/2JnDfCE
Music promoted by Audio Library https://youtu.be/tDexBj46oNI
===========================================================
Видео Python super function 🦸 канала Bro Code
#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):
self.length = length
self.width = width
class Square(Rectangle):
def __init__(self, length, width):
super().__init__(length,width)
def area(self):
return self.length*self.width
class Cube(Rectangle):
def __init__(self, length, width, height):
super().__init__(length,width)
self.height = height
def volume(self):
return self.length*self.width*self.height
square = Square(3, 3)
cube = Cube(3, 3, 3)
print(square.area())
print(cube.volume())
Bro Code merch store 👟 :
===========================================================
https://teespring.com/stores/bro-code-5
===========================================================
music credits 🎼 :
===========================================================
Up In My Jam (All Of A Sudden) by - Kubbi https://soundcloud.com/kubbi
Creative Commons — Attribution-ShareAlike 3.0 Unported— CC BY-SA 3.0
Free Download / Stream: http://bit.ly/2JnDfCE
Music promoted by Audio Library https://youtu.be/tDexBj46oNI
===========================================================
Видео Python super function 🦸 канала Bro Code
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
Python OOP Tutorial 4: Inheritance - Creating SubclassesA simple explanation of super() in PythonPython if __name__ == '__main__' ❓Python OOP Tutorial 6: Property Decorators - Getters, Setters, and Deleters__new__ vs __init__ in PythonObject Oriented Programming with Python - Full Course for BeginnersInheritance/Polymorphism in Object Oriented Programming | Python for Beginners | Code with Kylie #10Python Object Oriented Programming in 10 minutes 🐍Python snake game 🐍Python Full Course 🐍【𝙁𝙧𝙚𝙚】Java method overriding 🙅♂️Python Decorators in 15 MinutesPython inheritance 👪Python reduce ♻️Python higher order functions 👑Python return statement 🔙5 Things I Wish I Knew Before Starting ProgrammingC function prototypes 🤖Python Classes and Objects - OOP for Beginners