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
9 changes: 9 additions & 0 deletions exercises/exercise1.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ class Circle:
- No utilizar Properties
- Utilizar Type Hints en todos los métodos y variables
"""
def __init__(self, radio):
self.radio = radio

def area(self):
return round(pi*pow(self.radio, 2), 2)

def perimetro(self):
return round(2*pi*self.radio, 2)



# NO MODIFICAR - INICIO
Expand Down
15 changes: 15 additions & 0 deletions exercises/exercise2.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ 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 = round(self.costo + (self.costo * self.__iva) ,2)
return round(precio - (self.descuento * precio), 2)

@classmethod
def actualizar_iva(cls, iva):
cls.__iva = iva



# NO MODIFICAR - INICIO
Expand Down
15 changes: 15 additions & 0 deletions exercises/exercise3.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,22 @@ 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)
return round(precio - (self.descuento * precio), 2)

@classmethod
def actualizar_iva(cls, iva):
cls.__iva = iva

# NO MODIFICAR - INICIO
# Test parámetro obligatorio
Expand Down
13 changes: 13 additions & 0 deletions exercises/exercise4.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,20 @@
- 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[0]}, {self.longitud[1]}])"

def __len__ (self):
return len(self.longitud)

# NO MODIFICAR - INICIO
# Test parámetro obligatorio
try:
Expand Down
49 changes: 49 additions & 0 deletions exercises/exercise5.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,55 @@ def calcular_sueldos(contribuyentes: List[Contribuyente]):
"""Data una lista de contribuyentes, devuelve una lista de los sueldos de

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esta definida la funcion calcular_sueldos 2 veces. Una vacia y otra no.

cada uno."""

import abc
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import List


def calcular_sueldos(contribuyentes: List[Contribuyente]):
"""Data una lista de contribuyentes, devuelve una lista de los sueldos de
cada uno."""


def calcular_sueldos(contribuyentes: List):
lista = []
monotributista = contribuyentes[0]
empleado = contribuyentes[1]
lista.append(monotributista.calcular_sueldo())
lista.append(empleado.calcular_sueldo())

return lista


@dataclass
class Contribuyente(ABC):
sueldo: int

@dataclass
class Empleado(Contribuyente):
sueldo: int

def calcular_sueldo(self):
return self.sueldo - (self.sueldo* 0.17)


@dataclass
class Monotributista(Contribuyente):
sueldo: int

def calcular_sueldo(self):
if (self.sueldo*12 < 370000):
impuesto = 2646.22
elif(self.sueldo*12 < 550000):
impuesto = 2958.95
elif (self.sueldo*12 < 770000):
impuesto = 3382.62
else:
impuesto = 3988.85

return self.sueldo - impuesto


# NO MODIFICAR - INICIO
assert type(Contribuyente) == abc.ABCMeta, "Contribuyente debe ser abstracta"
Expand Down