-
Notifications
You must be signed in to change notification settings - Fork 8
feat: Creación y modificación de las funciones basic.py #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,519 @@ | |||
from datetime import datetime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hola, tienes duplicado este archivo, al hacerle un sha256 ambos tanto Basic como test son iguales, ten cuidado con eso.
Los test van separados del código principal, y las funciones van en src. Si necesitas traer funciones de src utiliza pytest o frameworks semejantes, te facilita mucho al momento de diseñar pruebas de tus funciones.
from src.funciones import suma
def test_suma():
assert suma(1,2,3)==6
luego en una terminal puedes ejecutarlo utilizando pytest
pytest test/*
if __name__ == "__main__": | ||
probar_calculadora() | ||
# Ejemplos de uso | ||
print("***Ejemplos de uso***\n") | ||
|
||
#Función de resta | ||
resultado = resta(20, 5, 2, 3, 4) | ||
print(f"Función resta - (20, 5, 2, 3, 4):",resultado) | ||
|
||
#Función de potencia | ||
resultado = potencia(10, 3) | ||
print(f"Función potencia - (10, 3):",resultado) | ||
|
||
#Función de raiz | ||
resultado = raiz(8, 3) | ||
print(f"Función raiz - (8, 3):",resultado) | ||
|
||
#Función si | ||
resultado = si(1==0, "Eso está bien", "Eso está mal") | ||
print(f"Función si - (1==0, 'Verdadero', 'Falso'):",resultado) | ||
|
||
#Función y | ||
resultado = y(True, True, False, True) | ||
print(f"Función y - (True, True, False, True):",resultado) | ||
|
||
#Función o | ||
resultado = o(True, False, False, False) | ||
print(f"Función o - (True, False, False, False):",resultado) | ||
|
||
#Función contar | ||
def test_contar(): | ||
assert CONTAR(1, 2.5, "texto", None) == 2 | ||
|
||
#Función contará | ||
def test_contara(): | ||
assert CONTARA(1, "", None, "hola", 0) == 4 | ||
|
||
#Función contar si | ||
def test_contar_si(): | ||
assert CONTAR_SI([1, 2, 3, 4], lambda x: x > 2) == 2 | ||
|
||
#Función buscarv | ||
def test_buscarv(): | ||
tabla = [["Ana", 30], ["Luis", 25]] | ||
assert BUSCARV("Luis", tabla, 1) == 25 | ||
|
||
#Función buscarh | ||
def test_buscarh(): | ||
tabla = [["Nombre", "Edad"], ["Ana", 30]] | ||
assert BUSCARH("Edad", tabla, 1) == 30 | ||
|
||
#Función concatenar | ||
def test_concatenar(): | ||
assert CONCATENAR("Hola", " ", "mundo", "!") == "Hola mundo!" | ||
|
||
# Ejemplos de uso con print() | ||
|
||
# Función concat | ||
print(concat("Hola", " ", "mundo")) # Output: Hola mundo | ||
print(concat("ACM", "UD", " 2025")) # Output: ACMUD 2025 | ||
|
||
# Función izquierda | ||
print(izquierda("ACMUD", 3)) # Output: ACM | ||
print(izquierda("Python", 2)) # Output: Py | ||
|
||
# Función derecha | ||
print(derecha("ACMUD", 2)) # Output: UD | ||
print(derecha("Programación", 4)) # Output: ción | ||
|
||
# Función largo | ||
print(largo("ACMUD")) # Output: 5 | ||
print(largo("Hola mundo")) # Output: 10 | ||
|
||
# Función ahora | ||
print(ahora()) # Output: 04-06-2025 21:59:12 (fecha y hora actual) | ||
|
||
# Función hoy | ||
print(hoy()) # Output: 04-06-2025 (solo fecha actual) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aquí no van los test, porque si bien lo que está dentro del if
no se ejecuta cuando es importado.
Tienes código fuera del if
que si se va a ejecutar en cada importe del módulo, lo cual puede hacer lento y complicado de ejecutar el código, siempre maneja los test en otro archivo.
Descripción
Participantes:
Jeison Steven Guio Varon
Gerson David Cruz Rodríguez
María Fernanda Velez Benitez
Miguel Esteban Pinilla Leal
En el siguiente archivo se desarrolló el modulo 4 "Basic" que implementa las funciones estándar, la validación de entradas, el soporte a funciones con número, variable de argumentos y su argumentación.
Tipo de cambio
Checklist