Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python Curso V2: 221 Ejercicio 9.11 Solicitar una Cantidad Arbitraria de Números y Calcular la Suma y el Producto.
- Loading branch information
Showing
3 changed files
with
52 additions
and
1 deletion.
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
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,26 @@ | ||
# Ejercicio 9.10: Realizar cálculos de estadísticos básicos: media, mínimo, máximo. | ||
|
||
numeros = [10, 2, 3, 4, 5, 6, 7, 8, 9, 1] | ||
|
||
suma = 0 | ||
|
||
for n in numeros: | ||
suma += n | ||
|
||
print('La suma es:', suma) | ||
|
||
minimo = numeros[0] | ||
|
||
for i in range(1, len(numeros)): | ||
if numeros[i] < minimo: | ||
minimo = numeros[i] | ||
|
||
print('El mínimo es:', minimo) | ||
|
||
maximo = numeros[0] | ||
|
||
for i in range(1, len(numeros)): | ||
if numeros[i] > maximo: | ||
maximo = numeros[i] | ||
|
||
print('El máximo es:', maximo) |
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 @@ | ||
# Ejercicio 9.11: Solicitar al usuario una cantidad arbitria de valor numéricos y luego calcular su suma y productoria. | ||
|
||
numeros = [] | ||
|
||
while True: | ||
cadena = input('Digite un número (o escriba "Salir" para terminar): ') | ||
|
||
if cadena.lower().strip() == 'salir': | ||
break | ||
|
||
numeros.append(float(cadena)) | ||
|
||
|
||
if len(numeros) > 0: | ||
suma = 0 | ||
producto = 1 | ||
|
||
for n in numeros: | ||
suma += n | ||
producto *= n | ||
|
||
print('Suma:', suma) | ||
print('Producto:', producto) | ||
else: | ||
print('No hay números en la lista.') |