Question: python You are Dr. Moreau and you will randomly create 20 bizarre animals. Each animal should have the following: A head randomly chosen from this
python
You are Dr. Moreau and you will randomly create 20 bizarre animals. Each animal should have the following:
-
A head randomly chosen from this list: snake, bull, lion, raven, bunny
-
A body made up of two animals randomly chosen using the petname library
-
A random number of arms; must be an even number and between 2-10, inclusive
-
A random number of legs; must be a multiple of three and between 3-12, inclusive
-
A non-random number of tails that is equal to the sum of arms and legs
Each of the 20 individual animals should be accessible from a list of dictionaries. Use the json library to dump your data structure into an animals.json file. For example, your assembled data structure may look like:
{ "animals": [ { "head": "snake", "body": "sheep-bunny", "arms": 2, "legs": 12, "tail": 14 }, { "head": "snake", "body": "parrot-bream", "arms": 6, "legs": 6, "tail": 12 }, ... etc Next, create a new Python script to read in animals.json and print the details of one animal at random to screen.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
