Posted by fduppafduppacomar on Wed 29 Apr 19:31
report abuse | View followups from Anonymous, lucas, Anonymous, facundo, facundo, german dobler and Anonymous | download | new post
- #!/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)
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.