fduppafduppacomar
By: a guest | Apr 29th, 2009 | Syntax:
Python | Size: 1.61 KB | Hits: 407 | Expires: Never
#!/usr/local/bin/python3.0
# Copyright (C) 2009 Federico Sebastian De Malmayne Duppa
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This program generates a random number between specified limits
import random
# Edit these variables accordingly
# amount = How many numbers are generated
# floor = minimum value
# roof = maximum value
#
# default values (eg Quini 6) amount = 6; floor = 0; roof = 45;
amount = 6
floor = 0
roof = 45
# End of editable space
while True:
# cleans control flag & throws away any leftovers in the list
li = []
control = 0
# appends elements to the list
for i in range (1, amount + 1):
aleatorio = random.randrange(floor, roof + 1)
li.append(aleatorio)
# check if there are repeated elements
for i in range (0, amount):
if li.count(li[i]) != 1:
control = control + 1
break
# if no repeated elemets, break the while
if control == 0:
break
li.sort()
print(li)