-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into lara_docker
- Loading branch information
Showing
113 changed files
with
79,004 additions
and
24 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,28 @@ | ||
# Evaluation Exercise - Create your first API using swagger | ||
Imagine that you work into industry compony where there is a robot. | ||
We have a sensor that is monitoring the temperature of robot via real-time. The measurement is saving into a database. | ||
Info from sensor; | ||
- id del sensor - string | ||
- fechamuestreo - string | ||
- unidad - string | ||
- medicion - number | ||
|
||
Our api needs create the next methods; | ||
> /getLastMeassureBySensor/{sensor}: | ||
sensor -> string | ||
When the methods is successful then this should return; | ||
Measure | ||
- code (id del sensor) - string | ||
- fechamuestreo - string | ||
- unidad - string | ||
- medicion - number | ||
|
||
When the method is not successful then this should return; | ||
404 -> Invalid ID supplied | ||
400 -> Sensor not found | ||
|
||
Steps: | ||
- Create your yaml | ||
- Check the format into https://editor.swagger.io/ | ||
|
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,57 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: Robot Sensor API | ||
version: 1.0.0 | ||
description: API for monitoring and retrieving robot temperature sensor data. | ||
|
||
paths: | ||
/getLastMeassureBySensor/{sensor}: | ||
get: | ||
summary: Retrieve the latest measurement by sensor ID | ||
parameters: | ||
- name: sensor | ||
in: path | ||
required: true | ||
description: The ID of the sensor to retrieve the latest measurement for. | ||
schema: | ||
type: string | ||
responses: | ||
'200': | ||
description: Successful retrieval of the latest measurement. | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
code: | ||
type: string | ||
description: ID of the sensor. | ||
fechamuestreo: | ||
type: string | ||
description: Timestamp of the measurement. | ||
unidad: | ||
type: string | ||
description: Unit of the measurement. | ||
medicion: | ||
type: number | ||
description: Value of the measurement. | ||
'400': | ||
description: Invalid ID supplied. | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
error: | ||
type: string | ||
example: Invalid ID supplied | ||
'404': | ||
description: Sensor not found. | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
error: | ||
type: string | ||
example: Sensor not found |
184 changes: 184 additions & 0 deletions
184
ALUMNOS/MDAB/CARLOS_OLIVER/PYTHON/Proyecto_Final/proyecto_final.py
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,184 @@ | ||
import re | ||
|
||
class Alumno: | ||
def __init__(self, nif, nombre, apellidos, telefono, email, aprobado=False): | ||
self.nif = nif | ||
self.nombre = nombre | ||
self.apellidos = apellidos | ||
self.telefono = telefono | ||
self.email = email | ||
self.aprobado = aprobado | ||
|
||
def mostrar_datos(self): | ||
estado = "Aprobado" if self.aprobado else "Suspendido" | ||
print(f"NIF: {self.nif}, Nombre: {self.nombre} {self.apellidos}, " | ||
f"Teléfono: {self.telefono}, Email: {self.email}, Estado: {estado}") | ||
|
||
|
||
class GestionAlumnos: | ||
def __init__(self): | ||
self.alumnos = [] | ||
|
||
def validar_email(self, email): | ||
patron_email = r"[^@]+@[^@]+\.[^@]+" | ||
if re.match(patron_email, email): | ||
return True | ||
else: | ||
print("Formato de email inválido. Asegúrate de que contenga un '@' y un dominio.") | ||
return False | ||
|
||
def añadir_alumno(self): | ||
nif = input("Introduce NIF: ") | ||
nombre = input("Introduce nombre: ") | ||
apellidos = input("Introduce apellidos: ") | ||
telefono = input("Introduce teléfono: ") | ||
|
||
while True: | ||
email = input("Introduce email: ") | ||
if self.validar_email(email): | ||
break | ||
|
||
alumno = Alumno(nif, nombre, apellidos, telefono, email) | ||
self.alumnos.append(alumno) | ||
print("Alumno añadido correctamente.") | ||
|
||
def eliminar_alumno_por_nif(self): | ||
nif = input("Introduce el NIF del alumno que deseas eliminar: ") | ||
for alumno in self.alumnos: | ||
if alumno.nif == nif: | ||
self.alumnos.remove(alumno) | ||
print("Alumno eliminado correctamente.") | ||
return | ||
print("Alumno no encontrado.") | ||
|
||
def actualizar_alumno_por_nif(self): | ||
nif = input("Introduce el NIF del alumno que deseas actualizar: ") | ||
for alumno in self.alumnos: | ||
if alumno.nif == nif: | ||
alumno.nombre = input(f"Introduce nuevo nombre (actual: {alumno.nombre}): ") | ||
alumno.apellidos = input(f"Introduce nuevos apellidos (actual: {alumno.apellidos}): ") | ||
alumno.telefono = input(f"Introduce nuevo teléfono (actual: {alumno.telefono}): ") | ||
|
||
# Validar el nuevo email | ||
while True: | ||
email = input(f"Introduce nuevo email (actual: {alumno.email}): ") | ||
if self.validar_email(email): | ||
alumno.email = email | ||
break | ||
|
||
print("Datos actualizados correctamente.") | ||
return | ||
print("Alumno no encontrado.") | ||
|
||
def mostrar_alumno_por_nif(self): | ||
nif = input("Introduce el NIF del alumno que deseas consultar: ") | ||
for alumno in self.alumnos: | ||
if alumno.nif == nif: | ||
alumno.mostrar_datos() | ||
return | ||
print("Alumno no encontrado.") | ||
|
||
def mostrar_alumno_por_email(self): | ||
email = input("Introduce el email del alumno que deseas consultar: ") | ||
for alumno in self.alumnos: | ||
if alumno.email == email: | ||
alumno.mostrar_datos() | ||
return | ||
print("Alumno no encontrado.") | ||
|
||
def listar_todos_los_alumnos(self): | ||
if not self.alumnos: | ||
print("No hay alumnos en la lista.") | ||
else: | ||
for alumno in self.alumnos: | ||
alumno.mostrar_datos() | ||
|
||
def aprobar_alumno_por_nif(self): | ||
nif = input("Introduce el NIF del alumno que deseas aprobar: ") | ||
for alumno in self.alumnos: | ||
if alumno.nif == nif: | ||
alumno.aprobado = True | ||
print(f"El alumno {alumno.nombre} ha sido aprobado.") | ||
return | ||
print("Alumno no encontrado.") | ||
|
||
def suspender_alumno_por_nif(self): | ||
nif = input("Introduce el NIF del alumno que deseas suspender: ") | ||
for alumno in self.alumnos: | ||
if alumno.nif == nif: | ||
alumno.aprobado = False | ||
print(f"El alumno {alumno.nombre} ha sido suspendido.") | ||
return | ||
print("Alumno no encontrado.") | ||
|
||
def mostrar_alumnos_aprobados(self): | ||
print("\nAlumnos Aprobados:") | ||
aprobados = [alumno for alumno in self.alumnos if alumno.aprobado] | ||
if aprobados: | ||
for alumno in aprobados: | ||
alumno.mostrar_datos() | ||
else: | ||
print("No hay alumnos aprobados.") | ||
|
||
def mostrar_alumnos_suspendidos(self): | ||
print("\nAlumnos Suspendidos:") | ||
suspendidos = [alumno for alumno in self.alumnos if not alumno.aprobado] | ||
if suspendidos: | ||
for alumno in suspendidos: | ||
alumno.mostrar_datos() | ||
else: | ||
print("No hay alumnos suspendidos.") | ||
|
||
def finalizar_programa(self): | ||
print("Finalizando programa. ¡Adiós!") | ||
exit() | ||
|
||
|
||
def mostrar_menu(): | ||
print("\n*** GESTIÓN DE ALUMNOS ***") | ||
print("(1) Añadir un alumno") | ||
print("(2) Eliminar alumno por NIF") | ||
print("(3) Actualizar datos de un alumno por NIF") | ||
print("(4) Mostrar datos de un alumno por NIF") | ||
print("(5) Mostrar datos de un alumno por Email") | ||
print("(6) Listar TODOS los alumnos") | ||
print("(7) Aprobar Alumno por NIF") | ||
print("(8) Suspender Alumno por NIF") | ||
print("(9) Mostrar alumnos aprobados") | ||
print("(10) Mostrar alumnos suspensos") | ||
print("(X) Finalizar Programa") | ||
|
||
|
||
def main(): | ||
gestion = GestionAlumnos() | ||
while True: | ||
mostrar_menu() | ||
opcion = input("Selecciona una opción: ").strip().upper() | ||
|
||
if opcion == "1": | ||
gestion.añadir_alumno() | ||
elif opcion == "2": | ||
gestion.eliminar_alumno_por_nif() | ||
elif opcion == "3": | ||
gestion.actualizar_alumno_por_nif() | ||
elif opcion == "4": | ||
gestion.mostrar_alumno_por_nif() | ||
elif opcion == "5": | ||
gestion.mostrar_alumno_por_email() | ||
elif opcion == "6": | ||
gestion.listar_todos_los_alumnos() | ||
elif opcion == "7": | ||
gestion.aprobar_alumno_por_nif() | ||
elif opcion == "8": | ||
gestion.suspender_alumno_por_nif() | ||
elif opcion == "9": | ||
gestion.mostrar_alumnos_aprobados() | ||
elif opcion == "10": | ||
gestion.mostrar_alumnos_suspendidos() | ||
elif opcion == "X": | ||
gestion.finalizar_programa() | ||
else: | ||
print("Opción no válida. Inténtalo de nuevo.") | ||
|
||
|
||
main() |
2 changes: 2 additions & 0 deletions
2
ALUMNOS/MDAB/CARLOS_OLIVER/PYTHON/Sesion1/Ejercicio1/Ejercicio1.py
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,2 @@ | ||
# Ejercicio 1 | ||
print("¡Hola, Mundo!") |
3 changes: 3 additions & 0 deletions
3
ALUMNOS/MDAB/CARLOS_OLIVER/PYTHON/Sesion1/Ejercicio2/Ejercicio2.py
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,3 @@ | ||
# Ejercicio 2 | ||
nombre = "Carlos" | ||
print(f"¡Hola, {nombre}!") |
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,25 @@ | ||
# Paso 1 | ||
print(" ¡Hola! Bienvenido al sistema de cálculo de inversiones ") | ||
print("===========================================================") | ||
cantidad = float(input(" ¿Cuánto deseas invertir hoy? Escribe la cantidad aquí: ")) | ||
|
||
# Paso 2 | ||
print("\n ¡Perfecto! Ahora vamos a establecer el interés que recibirás ") | ||
interes_anual = float(input(" ¿Cuál es el porcentaje de interés anual? (escribe solo el número): ")) | ||
|
||
# Paso 3 | ||
print("\n ¡Casi terminamos! Ahora, solo necesitamos saber el tiempo ") | ||
anos = int(input(" ¿Cuántos años planeas mantener esta inversión? ")) | ||
|
||
# Cálculo del interés compuesto | ||
cantidad_final = cantidad * (1 + (interes_anual / 100)) ** anos | ||
intereses_generados = cantidad_final - cantidad | ||
|
||
# Paso 4 Final | ||
print("\n ¡Listo! ") | ||
print("===========================================================") | ||
print(f"Después de {anos} años, habrás generado un interés total de: {intereses_generados:.2f}€ ") | ||
print(f"Tu inversión inicial de {cantidad:.2f}€ se convertirá en: {cantidad_final:.2f}€ ") | ||
print("===========================================================") | ||
print("Gracias por utilizar nuestro sistema de cálculo de inversiones. ¡Te deseamos mucho éxito! ") | ||
|
48 changes: 48 additions & 0 deletions
48
ALUMNOS/MDAB/CARLOS_OLIVER/PYTHON/Sesion3/Ejercicio1/Ejercicio1.py
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,48 @@ | ||
def calcular_inversion(): | ||
while True: | ||
# Paso 1 | ||
print("\n ¡Bienvenido al sistema de cálculo de inversiones ") | ||
print("===========================================================") | ||
cantidad = float(input(" ¿Cuánto deseas invertir hoy? Escribe la cantidad aquí: ")) | ||
|
||
# Paso 2 | ||
print("\n ¡Perfecto! Ahora vamos a establecer el interés que recibirás ") | ||
interes_anual = float(input(" ¿Cuál es el porcentaje de interés anual? (escribe solo el número): ")) | ||
|
||
# Paso 3 | ||
print("\n ¡Casi terminamos! Ahora, solo necesitamos saber el tiempo ") | ||
anos = int(input(" ¿Cuántos años planeas mantener esta inversión? ")) | ||
cantidad_final = cantidad * (1 + (interes_anual / 100)) ** anos | ||
intereses_generados = cantidad_final - cantidad | ||
|
||
# Paso 4 - Final | ||
print("\n ¡Listo! ") | ||
print("===========================================================") | ||
print(f"Después de {anos} años, habrás generado un interés total de: {intereses_generados:.2f}€ ") | ||
print(f"Tu inversión inicial de {cantidad:.2f}€ se convertirá en: {cantidad_final:.2f}€ ") | ||
print("===========================================================") | ||
|
||
opcion = input("\n¿Qué quieres hacer ahora?\n[1] Calcular una nueva inversión\n[X] Salir\n> ").upper() | ||
if opcion == "X": | ||
print("¡Nos vemos! ") | ||
exit() | ||
elif opcion != "1": | ||
print("Opción no válida. Volviendo al menú principal...") | ||
else: | ||
continue | ||
|
||
def main(): | ||
while True: | ||
print("\n Hola. Bienvenido al sistema de cálculo de inversiones. ¿Qué quieres hacer? ") | ||
print("[1] Calcular una inversión") | ||
print("[X] Salir") | ||
opcion = input("> ").upper() | ||
|
||
if opcion == "1": | ||
calcular_inversion() | ||
elif opcion == "X": | ||
print("¡Nos vemos! ") | ||
exit() | ||
else: | ||
print("Opción no válida. Por favor, introduce 1 o X.") | ||
main() |
14 changes: 14 additions & 0 deletions
14
ALUMNOS/MDAB/CARLOS_OLIVER/PYTHON/Sesion3/Ejercicio2/Ejercicio2.py
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,14 @@ | ||
print("Números primos entre 1 y 100:") | ||
|
||
for num in range(1, 101): | ||
es_primo = True | ||
if num < 2: | ||
es_primo = False | ||
else: | ||
for i in range(2, num): | ||
if num % i == 0: | ||
es_primo = False | ||
break | ||
|
||
if es_primo: | ||
print(num, end=" ") |
8 changes: 8 additions & 0 deletions
8
ALUMNOS/MDAB/CARLOS_OLIVER/PYTHON/Sesion3/Ejercicio3/Ejercicio3.py
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,8 @@ | ||
lista_anos = [1800, 2001, 2007, 2015, 2020, 2100] | ||
|
||
for ano in lista_anos: | ||
if (ano % 4 == 0 and ano % 100 != 0) or (ano % 400 == 0): | ||
print(f"El año {ano} es bisiesto.") | ||
else: | ||
print(f"El año {ano} no es bisiesto.") | ||
|
Oops, something went wrong.