pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Python pastebin - collaborative debugging tool View Help


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

  1. #!/usr/local/bin/python3.0
  2.  
  3. #   Copyright (C) 2009 Federico Sebastian De Malmayne Duppa
  4.  
  5. #   This program is free software: you can redistribute it and/or modify
  6. #   it under the terms of the GNU General Public License as published by
  7. #   the Free Software Foundation, either version 3 of the License, or
  8. #   (at your option) any later version.
  9.  
  10. #   This program is distributed in the hope that it will be useful,
  11. #   but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. #   GNU General Public License for more details.
  14.  
  15. #   You should have received a copy of the GNU General Public License
  16. #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  
  18. #    This program generates a random number between specified limits
  19.  
  20. import random
  21.  
  22. #   Edit these variables accordingly
  23. #   amount = How many numbers are generated
  24. #   floor = minimum value
  25. #   roof = maximum value
  26. #
  27. #   default values (eg Quini 6) amount = 6; floor = 0; roof = 45;
  28. amount = 6
  29. floor = 0
  30. roof = 45
  31. #    End of editable space
  32.  
  33. while True:
  34. #   cleans control flag & throws away any leftovers in the list
  35.     li = []
  36.     control = 0
  37. #   appends elements to the list
  38.     for i in range (1, amount + 1):
  39.         aleatorio = random.randrange(floor, roof + 1)
  40.         li.append(aleatorio)
  41. #   check if there are repeated elements
  42.     for i in range (0, amount):
  43.         if li.count(li[i]) != 1:
  44.             control = control + 1
  45.             break
  46. #   if no repeated elemets, break the while
  47.     if control == 0:
  48.         break
  49.  
  50. li.sort()
  51.  
  52. 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.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post