Last active
December 17, 2015 01:19
Revisions
-
nsabine revised this gist
Jul 8, 2013 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,14 @@ import random def random_int(num: int = 1, min: int = 1, max: int = 100) -> [int]: """Return a list of random integers.""" ints = [] for i in xrange(num): ints.append(random.randint(min,max)) return ints def random_word(num: int = 1) -> [str]: """Return a list of random words.""" with open('/usr/share/dict/words', 'rt') as f: words = f.readlines() allwords = [ w.rstrip() for w in words ] @@ -17,4 +19,4 @@ def random_word(num = 1): if __name__ == '__main__': print("Random Words: " + ','.join(random_word(5))) print("Random Integers: " + ','.join([str(i) for i in random_int(5)])) -
nsabine renamed this gist
May 6, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
nsabine created this gist
May 6, 2013 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ import random def random_int(num = 1, min = 1, max = 100): ints = [] for i in xrange(num): ints.append(random.randint(min,max)) return ints def random_word(num = 1): with open('/usr/share/dict/words', 'rt') as f: words = f.readlines() allwords = [ w.rstrip() for w in words ] words = [] for w in random.sample(allwords, num): words.append(w) return words if __name__ == '__main__': print("Random Words: " + ','.join(random_word(5))) print("Random Integers: " + ','.join([str(i) for i in random_int(5)]))