forked from mouredev/roadmap-retos-programacion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mouredev#4515 from NeosV/main
mouredev#8 - Python
- Loading branch information
Showing
2 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
|
||
|
||
class Programador: | ||
|
||
def __init__(self, nombre:str, edad:int, lenguaje:list): | ||
self.nombre = nombre | ||
self.edad = edad | ||
self.lenguaje = lenguaje | ||
|
||
def impri(self): | ||
print(f"Nombre: {self.nombre} Edad: {self.edad} Lenguaje: {self.lenguaje}") | ||
|
||
|
||
|
||
|
||
|
||
my_programador = Programador("Andres", 22 , ["css","Python"]) | ||
my_programador.impri() | ||
my_programador.edad = 24 | ||
my_programador.impri() | ||
|
||
|
||
class Stack: | ||
def __init__(self): | ||
self.stack = [] | ||
|
||
def anadir(self,item): | ||
|
||
self.stack.append(item) | ||
print("Accion completada") | ||
|
||
def eliminar(self): | ||
|
||
self.stack.pop() | ||
|
||
print("Eliminacion completada") | ||
|
||
def cont(self): | ||
|
||
print(len(self.stack)) | ||
|
||
def imprimir(self): | ||
|
||
for item in reversed(self.stack): | ||
print(item) | ||
|
||
|
||
|
||
|
||
my_stack = Stack() | ||
my_stack.anadir("a") | ||
my_stack.anadir("b") | ||
my_stack.anadir("c") | ||
my_stack.imprimir() | ||
my_stack.cont() | ||
my_stack.eliminar() | ||
my_stack.imprimir() | ||
|
||
|
||
class Queue: | ||
def __init__(self): | ||
self.queue = [] | ||
|
||
def anadir(self,item): | ||
|
||
self.queue.append(item) | ||
print("Accion completada") | ||
|
||
def eliminar(self): | ||
|
||
self.queue.pop(0) | ||
|
||
print("Eliminacion completada") | ||
|
||
def cont(self): | ||
|
||
print(len(self.queue)) | ||
|
||
def imprimir(self): | ||
|
||
for item in (self.queue): | ||
print(item) | ||
|
||
|
||
|
||
|
||
my_queue = Queue() | ||
my_queue.anadir("a") | ||
my_queue.anadir("b") | ||
my_queue.anadir("c") | ||
my_queue.imprimir() | ||
my_queue.cont() | ||
my_queue.eliminar() | ||
my_queue.imprimir() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
class Animal: | ||
|
||
def __init__(self,name): | ||
self.name = name | ||
|
||
def sound(self): | ||
pass | ||
|
||
|
||
|
||
class Perro(Animal): | ||
|
||
def sound(self): | ||
|
||
print("Guau") | ||
|
||
class Gato(Animal): | ||
|
||
def sound(self): | ||
|
||
print("Miau") | ||
|
||
|
||
my_animal = Animal("Animal") | ||
my_animal.sound() | ||
my_perro = Perro("Perro") | ||
my_perro.sound() | ||
my_gato = Gato("Gato") | ||
my_gato.sound() | ||
|
||
|
||
|
||
|
||
class Empresa: | ||
|
||
def __init__(self, id:int, name:str): | ||
|
||
self.id = id | ||
self.name = name | ||
self.empleados = [] | ||
|
||
|
||
def emplear(self, empleados): | ||
self.empleados.append(empleados) | ||
|
||
|
||
class Gerente(Empresa): | ||
|
||
def coordinar_proyectos(self): | ||
print(f"{self.name} esta coordinando los proyectos de la empresa") | ||
|
||
|
||
class Gerente_Proyecto(Empresa): | ||
|
||
def __init__(self, id: int, name: str, proyecto:str): | ||
super().__init__(id, name) | ||
self.proyecto = proyecto | ||
|
||
def coordinar_proyecto(self): | ||
print(f"{self.name} esta coordinando su proyecto {self.proyecto}") | ||
|
||
def proyecto_ger(self): | ||
print(f"{self.name} esta coordinando el {self.proyecto}") | ||
|
||
|
||
class Programador(Empresa): | ||
|
||
def __init__(self, id: int, name: str, lenguaje:str): | ||
super().__init__(id, name) | ||
self.lenguaje = lenguaje | ||
|
||
def programar(self): | ||
print(f"{self.name} esta programando en {self.lenguaje}") | ||
|
||
def emplear(self, empleados): | ||
print(f"un programdor no tiene empleados a su cargo") | ||
|
||
|
||
my_gerente= Gerente(1, "Andres") | ||
my_gerente_proyecto1= Gerente_Proyecto(2, "Jose", "Carrosdev" ) | ||
my_gerente_proyecto2= Gerente_Proyecto(3, "Carlos", "Motosdev") | ||
my_programador= Programador(4, "Maykol" , "Python") | ||
my_programador2= Programador(5, "Abraham" , "Go") | ||
|
||
my_gerente.emplear(my_gerente_proyecto1) | ||
my_gerente.emplear(my_gerente_proyecto2) | ||
|
||
my_gerente_proyecto1.emplear(my_programador) | ||
my_gerente_proyecto2.emplear(my_programador2) | ||
|
||
my_programador.emplear(my_programador2) | ||
my_programador.programar() | ||
|
||
my_gerente_proyecto1.coordinar_proyecto() | ||
|
||
my_gerente.coordinar_proyectos() |