Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions exercises/exercise1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion exercises/exercise2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 22 additions & 2 deletions exercises/exercise3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 11 additions & 0 deletions exercises/exercise4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
29 changes: 28 additions & 1 deletion exercises/exercise5.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
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"
Expand Down