opcion = 0
while opcion != 5:
print("\nSeleccione una opción:")
print("1) Sumar")
print("2) Restar")
print("3) Multiplicar")
print("4) Dividir")
print("5) Salir")
opcion = int(input("Ingrese la opción: "))
if opcion >= 1 and opcion <= 4:
n = int(input("¿Cuántos números desea ingresar? "))
numeros = []
for i in range(n):
numero = int(input(f"Ingrese el número {i + 1}: "))
numeros.append(numero)
if opcion == 1:
suma = 0
for num in numeros:
suma += num
print(f"La suma es: {suma}")
elif opcion == 2:
resta = numeros[0]
for num in numeros[1:]:
resta -= num
print(f"La resta es: {resta}")
elif opcion == 3:
producto = 1
for num in numeros:
producto *= num
print(f"La multiplicación es: {producto}")
elif opcion == 4:
division = numeros[0]
for num in numeros[1:]:
if num != 0:
division /= num
else:
print("No se puede dividir por 0.")
division = None
break
if division is not None:
print(f"La división es: {division}")
elif opcion == 5:
print("¡Hasta luego!")
else:
print("Opción no válida. Intente de nuevo.")
To embed this project on your website, copy the following code and paste it into your website's HTML: