Skip to content

Commit

Permalink
Cambios
Browse files Browse the repository at this point in the history
  • Loading branch information
indadominguez committed Oct 18, 2024
1 parent faa22e1 commit 6c24d39
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 3 deletions.
File renamed without changes.
4 changes: 1 addition & 3 deletions src/ej04_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ def convertir_temperatura():

celsius = float(input("Introduce la temperatura en grados Celsius: "))


fahrenheit = (celsius * 9/5) + 32


resultado = f"{celsius:.2f}ºC ({fahrenheit:.2f}ºF) ({celsius:.2f}ºC)"

return resultado

def main():
# Llamar a la función y mostrar el resultado

resultado = convertir_temperatura()
print(resultado)

Expand Down
25 changes: 25 additions & 0 deletions src/ej04_def2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# ejercicio 4_def_2

def grados_celsius(fahrenheit: float) -> float:

celsius = (fahrenheit - 32) * 5/9

return round(celsius, 2)

def convertir_temperatura():

fahrenheit = float(input("Introduce la temperatura en grados Fahrenheit: "))

celsius = grados_celsius(fahrenheit)

resultado = f"{fahrenheit:.2f}ºF ({celsius:.2f}ºC)"

return resultado

def main():

resultado = convertir_temperatura()
print(resultado)

if __name__ == "__main__":
main()
18 changes: 18 additions & 0 deletions src/prueba1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# prueba 1

def num_mayor(num1, num2):
if num1 > num2:
return num1
elif num2 > num1:
return num2
else:
return 0

def main():
numero1 = float(input("Ingrese el primer número: "))
numero2 = float(input("Ingrese el segundo número: "))
resultado = num_mayor(numero1, numero2)
print(f"El resultado es: {resultado:.2f}")

if __name__ == "__main__":
main()
5 changes: 5 additions & 0 deletions tests/test_ej01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import pytest
from src.ej01_def import dar_bienvenida

def test_dar_bienvenida():
assert dar_bienvenida("Indalecio") == ("Hola, Indalecio")
18 changes: 18 additions & 0 deletions tests/test_ej02.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pytest
from src.ej02_def import calcular_importe_total

@pytest.mark.parametrize(
"input_x, input_y, expected",
[
(4, 2, 8),
(1, 3, 3),
(2, 2, 4)
]
)
def test_calcular_importe_total(input_x, input_y, expected):
assert calcular_importe_total(input_x, input_y) == expected




Empty file added tests/test_ej04.py
Empty file.
15 changes: 15 additions & 0 deletions tests/test_prueba1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import pytest
from src.prueba1 import num_mayor


@pytest.mark.parametrize(
"input_x, input_y, expected",
[
(0, 0, 0),
(2, 1, 2),
(1, 2, 2)
]
)
def test_num_mayor(input_x, input_y, expected):
assert num_mayor(input_x, input_y) == expected

0 comments on commit 6c24d39

Please sign in to comment.