From e646488026f855f9d4f5276078b6e4a4f86cb3ef Mon Sep 17 00:00:00 2001 From: Santiago Date: Mon, 3 Oct 2022 17:18:28 -0300 Subject: [PATCH 1/2] =?UTF-8?q?Santiago=20Guarde,=20Legajo=2050621,=20Comi?= =?UTF-8?q?si=C3=B3n=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exercises/exercise1.py | 7 +++++++ exercises/exercise2.py | 17 ++++++++++++++++- exercises/exercise3.py | 24 ++++++++++++++++++++++-- exercises/exercise4.py | 11 +++++++++++ exercises/exercise5.py | 29 ++++++++++++++++++++++++++++- 5 files changed, 84 insertions(+), 4 deletions(-) diff --git a/exercises/exercise1.py b/exercises/exercise1.py index 4d88ccc..9840675 100644 --- a/exercises/exercise1.py +++ b/exercises/exercise1.py @@ -18,6 +18,13 @@ class Circle: - Utilizar Type Hints en todos los métodos y variables """ + def __init__(self, radio): + self.radio = radio + def area (self): + return round(pi*self.radio**2,2) + + def perimetro (self): + return round(2*self.radio*pi,2) # NO MODIFICAR - INICIO # Test básico diff --git a/exercises/exercise2.py b/exercises/exercise2.py index 2b02c90..bdf3c88 100644 --- a/exercises/exercise2.py +++ b/exercises/exercise2.py @@ -20,7 +20,22 @@ class Article: - No utilizar Properties - Utilizar Type Hints en todos los métodos y variables """ - + IVA = 0.21 + + def __init__(self, nombre, costo, descuento = 0): + self.nombre = nombre + self.costo = costo + self.descuento = descuento + + def calcular_precio (self): + precio_iva = round((self.costo * self.IVA) + self.costo,2) + precio = round((precio_iva - precio_iva * self.descuento),2) + return precio + + @classmethod + def actualizar_iva(cls, iva_nuevo): + cls.IVA = iva_nuevo + return cls.IVA # NO MODIFICAR - INICIO # Test parámetro obligatorio diff --git a/exercises/exercise3.py b/exercises/exercise3.py index 331440a..5683066 100644 --- a/exercises/exercise3.py +++ b/exercises/exercise3.py @@ -14,8 +14,28 @@ class Article: - No utilizar Dataclasses - Utilizar Type Hints en todos los métodos y variables """ - - + IVA = 0.21 + + def __init__(self, nombre, costo, descuento = 0): + self.nombre = nombre + self.costo = costo + self.descuento = descuento + + @property + def precio(self): + precio = round (self.costo + (self.costo * self.IVA),2) + precio_final = round (precio - (self.descuento * precio),2) + return precio_final + + def calcular_precio (self): + precio_iva = round((self.costo * self.IVA) + self.costo,2) + precio = round((precio_iva - precio_iva * self.descuento),2) + return precio + + @classmethod + def actualizar_iva(cls, iva_nuevo): + cls.IVA = iva_nuevo + return cls.IVA # NO MODIFICAR - INICIO # Test parámetro obligatorio try: diff --git a/exercises/exercise4.py b/exercises/exercise4.py index b424db7..4d19230 100644 --- a/exercises/exercise4.py +++ b/exercises/exercise4.py @@ -22,8 +22,19 @@ - No utilizar properties - Utilizar Type Hints en todos los métodos y variables """ +@dataclass +class Materia: + nombre: str +@dataclass +class Carrera: + longitud: list + def __str__(self): + return f"Carrera(materias={self.longitud})" + + def __len__(self): + return len(self.longitud) # NO MODIFICAR - INICIO # Test parámetro obligatorio try: diff --git a/exercises/exercise5.py b/exercises/exercise5.py index 92d717c..3bf3792 100644 --- a/exercises/exercise5.py +++ b/exercises/exercise5.py @@ -37,11 +37,38 @@ from dataclasses import dataclass from typing import List +@dataclass +class Contribuyente (ABC): + @abstractmethod + def calcular_sueldo(self): + pass + +@dataclass +class Empleado(Contribuyente): + sueldo : float + def calcular_sueldo(self): + return self.sueldo - (self.sueldo * 0.17) + +@dataclass +class Monotributista(Contribuyente): + sueldo:float + def calcular_sueldo(self) ->float: + if self.sueldo < (370000/12): + return self.sueldo - 2646.22 + elif self.sueldo < (550000/12): + return self.sueldo - 2958.95 + elif self.sueldo < (770000/12): + return self.sueldo - 3382.62 + elif self.sueldo > (770000/12): + return self.sueldo - 3988.85 def calcular_sueldos(contribuyentes: List[Contribuyente]): """Data una lista de contribuyentes, devuelve una lista de los sueldos de cada uno.""" - + sueldos= [] + for n in contribuyentes: + sueldos.append(n.calcular_sueldo()) + return sueldos # NO MODIFICAR - INICIO assert type(Contribuyente) == abc.ABCMeta, "Contribuyente debe ser abstracta" From 1a8c6038d75ff4f0e3f770fc1347841c570581af Mon Sep 17 00:00:00 2001 From: Santiago Date: Tue, 4 Oct 2022 11:00:23 -0300 Subject: [PATCH 2/2] Santiago Guarde Comision 3, legajo 50621 --- exercises/exercise5.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/exercise5.py b/exercises/exercise5.py index 3bf3792..612ba20 100644 --- a/exercises/exercise5.py +++ b/exercises/exercise5.py @@ -52,7 +52,7 @@ def calcular_sueldo(self): @dataclass class Monotributista(Contribuyente): sueldo:float - def calcular_sueldo(self) ->float: + def calcular_sueldo(self): if self.sueldo < (370000/12): return self.sueldo - 2646.22 elif self.sueldo < (550000/12):