Ministério da Educação
Brasil um país de todos
Personal tools
Navigation
Log in


Forgot your password?
 
Document Actions

lista5-ex4.py

by Cicero Garrozi last modified 2015-09-25 05:49

Click here to get the file

Size 1 kB - File type text/python-source

File contents

from random import randint, shuffle

unidades = [0,1,2,3,4,5,6,7,8,9]
dezenas = [0,1,2,3,4,5,6,7,8,9]

listaSorteados = []
sorteadas = 0
while sorteadas <= 5:
    #embaralhando listas:
    shuffle(unidades)
    shuffle(dezenas)
    u = randint(0,9)
    d = randint(0,9)
    if u != 0 and d != 0:
        numero = int("%d%d"%(d,u))
    else: #saiu 00, considerar 100
        numero = 100
    if numero not in listaSorteados:
        print("Numero sorteado: %d"%(numero))
        listaSorteados.append(numero)
        sorteadas += 1
    #else:
    #    print("Repetiu o numero ", numero)

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: