Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Requirements: Given a poorly written Python script, poor _ chinese _ zodiac.py , that determines the Chinese Zodiac sign for a year input by the
Requirements:
Given a poorly written Python script, poorchinesezodiac.py that determines the
Chinese Zodiac sign for a year input by the user, write a wellstructured Python script,
chinesezodiac.py that uses functions and a list to get the same result.
The Chinese Zodiac is based on a year cycle, with each year represented by an animal
monkey, rooster, dog, pig, rat, ox tiger, rabbit, dragon, snake, horse, and sheep.
Note that year determines the Zodiac sign. For example, is the year of the rat
because
Below is the code for poorchinesezodiac.py
Your job is to restructure the code. Here are the requirements for restructuring:
There should be a main function, a getinput function, and a
getzodiacanimal function.
The main function should get the user's input, year, from getinput.
The main function should send year to getzodiacanimal.
The getzodiacanimal function should return to main the name of the
appropriate animal.
Use a list of animals in the getzodiacanimal function.
signs monkey 'rooster', 'dog', 'pig',
'rat', ox 'tiger', 'rabbit',
'dragon', 'snake', 'horse', 'sheep'
You can determine which element of signs you want by calculating the index as
animalyear year
SampleOutput:
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