8000 added random name generator · wmskalski/python-scripts@ec099c8 · GitHub
[go: up one dir, main page]

Skip to content

Commit ec099c8

Browse files
committed
added random name generator
1 parent 9c02c43 commit ec099c8

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

13_random_name_generator.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from random import randint
2+
3+
4+
def random_name_generator(first, second, x):
5+
"""
6+
Generates random names.
7+
Arguments:
8+
- list of first names
9+
- list of last names
10+
- number of random names
11+
"""
12+
names = []
13+
for i in xrange(0, int(x)):
14+
random_first = randint(0, len(first)-1)
15+
random_last = randint(0, len(second)-1)
16+
names.append("{0} {1}".format(
17+
first[random_first],
18+
second[random_last])
19+
)
20+
return set(names)
21+
22+
23+
first_names = ["Drew", "Mike", "Landon", "Jeremy", "Tyler", "Tom", "Avery"]
24+
last_names = ["Smith", "Jones", "Brighton", "Taylor"]
25+
names = random_name_generator(first_names, last_names, 5)
26+
print '\n'.join(names)

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
1. **10_find_files_recursively.py**: recursively grab files from a directory
1313
1. **11_optimize_images_with_wand.py**: recursively grab images from a directory, then optimize them for the web
1414
1. **12_csv_split.py**: Splits a CSV file into multiple files based on command line arguments.
15+
1. **13_random_name_generator.py**: random name generator

0 commit comments

Comments
 (0)
0