Rand_name = ' '. Use a for loop, random.randint() is used to generate random numbers which are them appending to a list. Then we want to generate a list of 1) only upper case words, 2) only "name like" words (i.e., not abbreviations), and 3) a sort-of-realistic-but-fun sounding random name from the list: import random Take the number of elements from the user. 'abbas', 'abbe', 'abbey', 'abbot', 'Abbott', 'abbreviate'. The string module contains Ascii string constants in various text cases. 'aback', 'abacus', 'abalone', 'abandon', 'abase', 'abash', 'abate', In order to generate random strings in Python, we use the string and random modules. random.uniform() returns a random floating. ['a', 'AAA', 'AAAS', 'aardvark', 'Aarhus', 'Aaron', 'ABA', 'Ababa', How to create Random Numbers in Python random.random() returns a random floating number between 0 and 1. The first bit of code grabs a disctionary listing from the web and returns a list of all the entries in that dictionary. randrange() to Generate List of Integers 3. Complete random name function in next file. randint() to Generate List of Integers 2. The following code is written for Python3.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |