lista5ex4.py
Click here to get the file
Size
1 kB
-
File type
text/python-source
File contents
from random import randint
from random import shuffle
#este trecho eh identico ao shuffle:
lista = [None]*10
pos = 0
while None in lista:
numero = randint(0, 9)
if numero not in lista:
lista[pos] = numero
pos += 1
#outra maneira:
#suffle(lista)
dezenas = range(6)
unidades = range(10)
sorteados = []
i = 0
while i < 6: #sorteando os numeros da mega sena:
shuffle(dezenas)
shuffle(unidades)
#sorteando a unidade e a dezena:
u = unidades[randint(0,9)]
d = dezenas[randint(0,5)]
if u == 0 and d == 0:
d = 6
numero = int("%s%s"%(d,u))
if numero not in sorteados:
sorteados.append(numero)
i += 1
print "numeros sorteados: "," ".join([str(k) for k in sorteados])