Wolfram Archive
Wolfram Programming Lab is a legacy product.
All the same functionality and features, including access to Programming Lab Explorations, are available with Wolfram|One.
Start programming now. »
Try it now »
(no sign-in required)

# Make Up a Random Name

Create random pronounceable nicknames for yourself and your friends.

Run the code to make a random sequence of 6 letters. Try it several times; try lengths other than 6:

This gives the list of characters from a to z:

CharacterRange["a", "z"]

RandomChoice chooses a random character from the list. Each time you run the code, you get a different choice:

RandomChoice[CharacterRange["a", "z"]]

This gives a list of 6 random characters:

RandomChoice[CharacterRange["a", "z"], 6]

RandomChoice[CharacterRange["a", "z"], 6]

Get lists of vowels and consonants. Try adding y to the list of vowels:

Make a list of the vowels and give it the name vowels:

vowels = {"a", "e", "i", "o", "u"}

Using the name vowels is the same as using the list:

vowels

Complement gives all of the elements of the first list that are not in the second list. For example:

Complement[{1, 2, 3, 4, 5}, {2, 4}]

The consonants are the letters that are not vowels:

consonants = Complement[CharacterRange["a", "z"], vowels]

vowels = {"a", "e", "i", "o", "u"}; consonants = Complement[CharacterRange["a", "z"], vowels]

Make random words out of 4 letters. Try other patterns of consonants and vowels:

Note: be sure you have already run the previous step.

This gives a random consonant:

RandomChoice[consonants]

This gives a random vowel:

RandomChoice[vowels]

String together consonants and vowels in a list to make random words:

{RandomChoice[consonants], RandomChoice[vowels], RandomChoice[consonants], RandomChoice[vowels]}

{RandomChoice[consonants], RandomChoice[vowels], RandomChoice[consonants], RandomChoice[vowels]}

Make a list of 4 alternations of consonants and vowels. Try numbers other than 4:

Table makes lists of things.

This makes a list of 4 random consonants:

Table[RandomChoice[consonants], {4}]

This makes a list of 4 consonant-vowel lists:

Table[{RandomChoice[consonants], RandomChoice[vowels]}, {4}]

Flatten flattens out the sublists:

Flatten[Table[{RandomChoice[consonants], RandomChoice[vowels]}, {4}]]

Flatten[Table[{RandomChoice[consonants], RandomChoice[vowels]}, {4}]]

Display the letters as a word in 40-point type. Try changing the size to something other than 40for example, 80:

StringJoin joins text strings in a list into a single text string:

StringJoin[{"wolf", "ram"}]

Use it to make a word out of a list of random letters:

StringJoin[ Flatten[Table[{RandomChoice[consonants], RandomChoice[vowels]}, {4}]]]

Change the size of text with Style. This writes wolfram in 40-point text (a point is a printers measure equal to 1/72 inch):

Style["wolfram", 40]

Write a random word in 40-point text:

Style[StringJoin[ Flatten[Table[{RandomChoice[consonants], RandomChoice[vowels]}, {4}]]], 40]

Style[StringJoin[ Flatten[Table[{RandomChoice[consonants], RandomChoice[vowels]}, {4}]]], 40]

Make a column of 6 random names. Try numbers of names other than 6:

Column formats lists of things as columns:

Column[{"one", "two", "three", "four"}]

Make a list of 6 random names:

Table[Style[ StringJoin[ Flatten[Table[{RandomChoice[consonants], RandomChoice[vowels]}, {4}]]], 40], {6}]

Use Column to format the names in a column:

Column[Table[ Style[StringJoin[ Flatten[Table[{RandomChoice[consonants], RandomChoice[vowels]}, {4}]]], 40], {6}]]

Column[Table[ Style[StringJoin[ Flatten[Table[{RandomChoice[consonants], RandomChoice[vowels]}, {4}]]], 40], {6}]]

Share Itmake a website that gives you a different random name each time you visit it:

Deploy the random name code to the Wolfram Cloud, where anyone can use it:

CloudDeploy[ Delayed[ExportForm[ vowels = {"a", "e", "i", "o", "u"}; consonants = Complement[CharacterRange["a", "z"], vowels]; Style[StringJoin[ Flatten[Table[{RandomChoice[consonants], RandomChoice[vowels]}, {4}]]], 40], "PNG"]], "Permissions" -> "Public" ]

Click the link in the output to visit the site. Refresh the page in your browser to get a new random name.