Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

herencia python

class Persona:
    def __init(self, nombre):
        self.nombre = nombre

class Estudiante(Persona):
    def __init(self, nombre, curso):
        super().__init__(nombre)
        self.curso = curso 
Comment

python herencia

class Coordinates:
    def __init__(self, x, y):
        self.__x = x #variables that start with double _ are private and only can be accessed by method
        self.__y = y
    def x(self):
        return self.__x
    def y(self):
        return self.__y
    def position(self):
        return (self.__x, self.__y)

class Square(Coordinates):
    def __init__(self, x, y, w, h):
        super().__init__(x, y)
        self.__w = w
        self.__h = h
    def w(self):
        return self.__w
    def h(self):
        return self.__h
    def area(self):
        return self.__w * self.__h

class Cube(Square):
    def __init__(self, x, y, w, h, d):
        super().__init__(x,y,w,h)
        self.__d = d
    def d(self):
        return self.__d
    def area(self): #overwrites square area function
        return 2 * (self.__w * self.__h + self.__d * self.__h + self.__w * self.__d)
    def volume(self):
        return self.__w * self.__h * self.__d
Comment

PREVIOUS NEXT
Code Example
Python :: python invert binary tree 
Python :: python pyqt5 
Python :: pandas dataframe column based on another column 
Python :: remove all rows with at least one zero pandas 
Python :: combination of 1 2 3 4 5 python 
Python :: how do i limit decimals to only two decimals in python 
Python :: create pytorch zeros 
Python :: find sum of factors of a number python 
Python :: how to import opencv in python 
Python :: yaxis on the right matplotlib 
Python :: read excel spark 
Python :: how to open ndjson file in python 
Python :: python isinstance list 
Python :: beautifulsoup find get value 
Python :: install python 3.8 
Python :: ppcm python 
Python :: python int to binary 
Python :: how to check if an element is in a list python 
Python :: Django custome login 
Python :: one hot encoding 
Python :: python filter data from list 
Python :: python format 001 
Python :: matplotlib subplots 
Python :: set allowed methods flask 
Python :: How to rotate the 2D vector by degree in Python: 
Python :: numpy rolling average 
Python :: echo $pythonpath ubuntu set default 
Python :: change dataframe to list 
Python :: jsonschema in python 
Python :: get query params flask 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =