Question
Question Problem In Python Code: Create a simple funny nickname generator. The generator runs a number of times and builds a list of nicknames. At
Question Problem
In Python Code: Create a simple funny nickname generator. The generator runs a number of
times and builds a list of nicknames. At each iteration, it randomly picks the first
name from a list of adjectives and the last name from a list of nouns. It then
capitalizes both the first and the last name and adds the nickname to a list of strings.
After it completes the given number of iterations, the generator returns the list of
nicknames.
-
- You are asked to write a function definition that implements this nickname generator. The function is called nickname_generator() and takes three parameters:
- adjectives and nouns are two lists of strings, representing adjectives and nouns
- limit is a number that controls how many times the generator runs.
- The function returns a list of strings.
- To better understand what the function does, consider that you'll do the following testing.
- You create two lists of adjectives and nouns:
adjectives = ['fabulous', 'squishy', 'evil', 'fuzzy', 'smooth', 'nosy', 'bitter', 'salty', 'mammoth', 'sweet', 'grumpy',
'modern', 'shivering']
nouns = ['elephant', 'phone', 'bug', 'string', 'nose', 'finger', 'tongue', 'laptop', 'koala', 'panda', 'mouse']
- You call the function, save its return value in the variable result, and print out the result as below:
result = nickname_generator (adjectives, nouns, 10)
print(result)
- If you have your function definition and the testing above in an Active Code, each time you save and run you get something different, for example:
['Mammoth Nose', 'Evil Panda', 'Shivering Finger', 'Evil Finger', 'Sweet String', 'Fabulous Laptop', 'Nosy Tongue', 'Fabulous Laptop', 'Shivering Phone', 'Fabulous Bug']
- Think about how to solve this problem and the computational steps of your solution BEFORE you write the Python code. Explain (1) what computations youll instruct Python to do; and (2) why. - Write your explanations here.
- Using the explanations of the computational steps of your solution, in an Active Code scratchpad, write the function definition and the testing implementation.
- Copy and paste the code of your function definition here.
- Copy and paste the output you get when you run & save your code here.
- What was the most challenging while solving Problem 3? Why?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started