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 import list from py file 
Python :: dm command in discord.py 
Python :: print python reverse list 
Python :: dataframe.fillna 
Python :: how to find duplicate strings in a list of string python function 
Python :: how to compare list and int in python 
Python :: circular dependencies in python 
Python :: class __call__ method python 
Python :: check package is installed by conda or pip environment 
Python :: count TRUE in DF 
Python :: zip() python 
Python :: how to download a pip package with python and os 
Python :: python create dictionary 
Python :: dictionary multiple values per key 
Python :: python post request multi argument 
Python :: permutation and combination program in python 
Python :: continue statement in python 
Python :: django reverse vs reverse_lazy 
Python :: matplotlib multiple bar plot 
Python :: add item to list python 
Python :: determinant of 3x3 numpy 
Python :: python basic data types 
Python :: create a colun in pandas using groupby 
Python :: convert string to datetime python 
Python :: python built in libraries 
Python :: how to access pandas column 
Python :: e in python 
Python :: regex python 
Python :: How to solve not in base 10 in python when using decimals 
Python :: Python RegEx Subn – re.subn() 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =