Question

Create a Python program that generates 20 random Names into a list.

Create a Python program that generates 20 random Names into a list.

Homework Answers

Answer #1
import random
result = []
alphabets = "abcdefghijklmnopqrstuvwxyz"
for i in range(20):
    # Generating number of characters in the name
    nameLength = random.randint(3,7)
    name = ""
    for j in range(nameLength):
        name += alphabets[random.randint(0,25)]
    result.append(name)
print("20 random Names list:")
print(result)

20 random Names list:
['pouhgct', 'wzqnkaj', 'khpvrsv', 'vnv', 'tncyuhm', 'omx', 'tks', 'hurd', 'bdqh', 'kutt', 'mcfvm', 'odsupi', 'llv', 'qchlop', 'phlri', 'qnqoifj', 'tyq', 'bvpcnc', 'saspgcu', 'xla']
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Create a Python program that: Allows the user to enter a phrase or sentence. The program...
Create a Python program that: Allows the user to enter a phrase or sentence. The program should then take the phrase or sentence entered Separate out the individual words entered Each individual word should then be added to a list After all of the words have been place in a list Sort the contents of the list Display the contents of the sorted list with each individual word displayed on a separate line Display a message to the user indicating...
Python Question: Create a program that prints the majority vote in a list. A majority vote...
Python Question: Create a program that prints the majority vote in a list. A majority vote is an element that occurs > N/2 times in a list (where N is the length of the list). Examples ["A", "A", "B"] ➞ "A" ["A", "A", "A", "B", "C", "A"] ➞ "A" ["A", "B", "B", "A", "C", "C"] ➞ None
In python.....Create a Linked List program using at least 15 items. Must use the following in...
In python.....Create a Linked List program using at least 15 items. Must use the following in your program: Min() Max() Index() Count() Remove() Note: Use the "print" statement after each method.
6) Write the Python Code which can answer the following questions (20 pts): a)Consider a program...
6) Write the Python Code which can answer the following questions (20 pts): a)Consider a program which contains a list of numbers from 1 to 10that are stored into a variable a. Create a program that will allow you to exchange the elements from variable a at position 0 and 7from within this list. b)Create a program that will access the last 5 elements of the variable a from step a.)
Write a python program that generates a sudoku puzzle.1. Enter n (which is the size of...
Write a python program that generates a sudoku puzzle.1. Enter n (which is the size of the sudoku puzzle #2. Keep generating random permutations of n using python built in function until you find permutation that can be incorporated as a new component of the sudoku grid. format for puzzle should be output 1 2 3 3 1 2 2 3 1
The file scores.txt (attached above) contains a list of names and test scores. Create a program...
The file scores.txt (attached above) contains a list of names and test scores. Create a program that reads each line of the file and determines the highest score and who obtained it. This is an exercise in strings. You are required to use at least one string method to determine the names and the scores. Your output should resemble the following: Highest Score: 100 Achieved by: Jay The text file looks like this: Jan 86 Drew 92 Blake 85 Alex...
Write a program that generates a vector with 30 random integers between –10 and 20 and...
Write a program that generates a vector with 30 random integers between –10 and 20 and then finds the maximum of all the elements that are divisible by 3. if you can explain how you got to finding the maximum it well help. also please use matlab
Create a program that allows the user to input a list of first names into one...
Create a program that allows the user to input a list of first names into one array and last names into a parallel array. Input should be terminated when the user enters a sentinel character. The output should be a list of emial addresses where the address is of the following form: [email protected] Declare FirstName[100] as String Declare LastName[100] as String Declare email as String Declare K as Integer Declare index as Integer Write "Enter first and last name." Write...
Write a program in Python using loop that asks for the names of three runners and...
Write a program in Python using loop that asks for the names of three runners and the time it took each of them to finish a race. The program should display who came in first, second, and third place. Think about how many test cases are needed to verify that your problem works correctly.
Create a Python for loop script of exactly 2 lines of code that generates a sequence...
Create a Python for loop script of exactly 2 lines of code that generates a sequence of integer numbers that start in zero and go to (and include) the number 25. For each integer generated, print in the Python console the following string (for instance if you have generated the number five): Generated number: 5.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT