Encontramos la solución a esta interrogante, o por lo menos eso pensamos. Si sigues con preguntas coméntalo y sin dudarlo te ayudaremos
Ejemplo 1: hacer una instancia de una clase en puython
#!/usr/bin/pythonclassEmployee:'Common base class for all employees'
empCount =0def__init__(self, name, salary):
self.name = name
self.salary = salary
Employee.empCount +=1defdisplayCount(self):print"Total Employee %d"% Employee.empCount
defdisplayEmployee(self):print"Name : ", self.name,", Salary: ", self.salary
"This would create first object of Employee class"
emp1 = Employee("Zara",2000)"This would create second object of Employee class"
emp2 = Employee("Manni",5000)
emp1.displayEmployee()
emp2.displayEmployee()print"Total Employee %d"% Employee.empCount
Ejemplo 2: objeto de instancia de Python
x.counter =1while x.counter <10:
x.counter = x.counter *2print(x.counter)del x.counter
#https://docs.python.org/3.8/tutorial/classes.html#class-objects
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)