Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: UTF-8 -*-
- __author__ = 'Julio Tentor jtentor@gmail.com'
- import random
- def consola():
- cantidad = int(input("Ingrese la cantidad de números a procesar: "))
- if cantidad > 0:
- mayor = 0
- menor = 0
- primeravez = True
- suma = 0
- for i in range(0, cantidad):
- numero = int(input("Ingrese el número (" + str(i + 1) + "): "))
- if primeravez:
- mayor = numero
- menor = numero
- primeravez = False
- else:
- if numero > mayor:
- mayor = numero
- if numero < menor:
- menor = numero
- suma += numero
- print("Mayor: " + str(mayor))
- print("Menor: " + str(menor))
- print("Promedio: " + str(suma / cantidad))
- def automatico():
- cantidad = random.randrange(10, 50)
- if cantidad > 0:
- mayor = 0
- menor = 0
- primeravez = True
- suma = 0
- for i in range(0, cantidad):
- numero = random.randrange(100) * random.choice([-1,1,1,1,1])
- print(numero, end=" ")
- if primeravez:
- mayor = numero
- menor = numero
- primeravez = False
- else:
- if numero > mayor:
- mayor = numero
- if numero < menor:
- menor = numero
- suma += numero
- print()
- print("Mayor: " + str(mayor))
- print("Menor: " + str(menor))
- print("Promedio: " + str(suma / cantidad))
- #automatico()
- consola()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement