• Lenguaje

    Python

  • Descripción

    De un conjunto de N numeros seleccionar el mayor y y el manor y realizar el promedio de todo el conjunto de datos.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os

mayor = 0
menor = 0
promedio = 0
n = int (input ('Ingresa el valor de n: '))
for i in range (1, n + 1):
    print ('PROCESO ' + repr (i))
    un_numero = float (input ('Ingresa el valor de un numero: '))
    if i==1 or un_numero<mayor:
        mayor=un_numero
    if i==1 or un_numero>menor:
        menor=un_numero
    promedio=promedio+un_numero
    print ()
if n == 0:
    promedio = 0
else:
    promedio=promedio/n
print ('Valor de mayor: ' + repr (mayor))
print ('Valor de menor: ' + repr (menor))
print ('Valor de promedio: ' + repr (promedio))
os.system ('pause')