Answered step by step
Verified Expert Solution
Link Copied!

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, poor_chinese_zodiac.py, that determines the
Chinese Zodiac sign for a year input by the user, write a well-structured Python script,
chinese_zodiac.py, that uses functions and a list to get the same result.
The Chinese Zodiac is based on a 12-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 %12 determines the Zodiac sign. For example, 1900 is the year of the rat
because 1900%12=4.
Below is the code for poor_chinese_zodiac.py.
Your job is to restructure the code. Here are the requirements for restructuring:
There should be a main function, a get_input function, and a
get_zodiac_animal function.
The main function should get the user's input, year, from get_input.
The main function should send year to get_zodiac_animal.
The get_zodiac_animal function should return to main the name of the
appropriate animal.
Use a list of animals in the get_zodiac_animal 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
animal_year = year %12.
SampleOutput:
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

7. Identify six intercultural communication dialectics.

Answered: 1 week ago