Question: How to modify a Chinese program to allow users to choose between Chinese, Japanese, or Vietnamese zodiacs. I can do the first portion, however, the

How to modify a Chinese program to allow users to choose between Chinese, Japanese, or Vietnamese zodiacs.

I can do the first portion, however, the modification portion keeps getting me stumped. I included the first portion as well to show the basis my program is made from.How to modify a Chinese program to allow users to choose betweenChinese, Japanese, or Vietnamese zodiacs. I can do the first portion, however,the modification portion keeps getting me stumped. I included the first portionas well to show the basis my program is made from. odayWe are 8oin8 to Step througn a prograrm Lnat deterrmines the animialand assoclated characteristics from the Chinese Zodiac for a given year of

oday We are 8oin8 to Step througn a prograrm Lnat deterrmines the animial and assoclated characteristics from the Chinese Zodiac for a given year of birth. This program is going to help with practice with tuples, while loops, if statements, booleans and introduce you to the datetime modu Here are two examples of what the program execution will look like when you are done writing th program Program Execution: This program will display your Chinese zodiac sign and associated personal characteristics Enter your year of birth (yyyy) 2004 Your Chinese zodiac sign is the Rooster Your personal characteristics Motivator, inquisitive, flexible, innovative, problem solver Would you like to enter another year? (y): 1986 Please enter 'y' or 'n': y Enter your year of birth (yyyy) 1986 Your Chinese zodiac sign is the Tiger Your personal characteristics Unpredictable, rebellious, passionate, daring, impulsive Would you like to enter another year? (y): n 3) The first thing we need to do is initialize our variables/tuples and import any modules that we will need. The datetime module supplies us with classes and functions that we can use to manipulate dates and times. To find out more about what is available when you import the datetime module you can check out the documentation at the following link https://docs.python.org/3.7/library/datetime.html. We will need to import the datetime module so that we get the current date and use it in our algorithm. a. import datetime b. The 12 animals of the Chinese Zodiac are the Rat, Ox, Tiger, Rabbit, Dragon, Snake, Horse, Goat, Monkey, Rooster, Dog, and Pig. Create a tuple of strings called zodiac animals that contains the 12 animals used in the Chinese Zodiac zodiac-animals Horse', Goat - ("Rat', 'Ox', 'Tiger', "Rabbit', 'Dragon', 'Monkey', 'RoosterDog','Pig') 'Snake ' , For each animal in the Chinese Zodiac there is a description of characteristics associated with that animal. For each animal, we are going to create a variable that holds the string of characteristics c. rat = 'Forthright, industrious, sensitive, intellectual, sociable' ox- "Dependable, methodical, modest, born leader, patient' tiger 'Unpredictable, rebellious, passionate, daring, impulsive' rabbit 'Good friend, kind, soft-spoken, cautious, artistic' dragonStrong, self-assured, proud, decisive, loyal' snake'Deep thinker, creative, responsible, calm, purposeful horse'Cheerful, quick-witted, perceptive, talkative, open-minded' goat-'Sincere, sympathetic, shy, generous, mothering monkey = "Motivator, inquisitive, flexible, innovative, problem solver rooster'Organized, self-assured, decisive, perfectionist, zealous dog -'Honest, unpretentious, idealistic, moralistic, easy going' pig 'Peace-1loving, hard-working,trusting, understanding, thoughtful' d. Now that we have variables for each animal that has been assigned to the string of characteristics, we are going to create a tuple of those representative variables. Createa tuple called characteristics that holds the string variables we just created characteristics-(rat, ox, tiger, rabbit, dragon, snake, horse, goat, monkey, rooster, dog, pig) Based on the program execution we saw above, we know that this program should continue running until the user tells us to terminate. We will need a Boolean variable to control a while loop we will create soon. For now, create a Boolean variable called terminate and assign it the value of False because we don't want to terminate the loop the first time we enter it. e. terminate False f. The next step is to print out the program greeting and let the user know the purpose of the program print ('This program will display your Chinese zodiac sign and associated') print ('personal characteristics. ') In order to figure out the users zodiac animal we are going to need to know the current year and rather than hardcoding in the current year. We are going to utilize the datetime module to get the year for us. I want you to create a variable called current_yr and assign it the value returned from the current year function, using dot notation to get to the appropriate property. The syntax to do this is as follows g. current_yrdatetime.date.today().year Now that we have initialized all of the data, we are now going to work on the control of the program. I provided you with the lines of code you needed, but for the next part I am going to provide you with the step by step algorithm and 90% of what you need. You will need to translate this algorithm into the appropriate syntax using the variables/tuples you created above and any variables Itell you to create in the algorithm Here is the algorithm for the functionality of the program while the user does not want to terminate the program prompt the user to enter the year of their birth, typecast it to an integer and store it in the variable birth_year.The result of this line of code should produce output like the sample execution above and given here output: Enter your year of birth (yyyy) while the user didn't enter a valid birth_year, which for the Chinese zodiac is anything less than 1900 and greater than the current year print a message telling them it was an invalid birth_year output: Invalid year. Please re-enter ask the user to enter the year of their birth, so you can check it again output: Enter your year of birth (yyyy) Now that the user has entered a valid input, we need to calculate what zodiac animal the user is and store it into a variable called cycle_ num. To find the cycle_num it is the (birth-year - 1900)812 Next, we print out a message to the user telling them what their Chinese Zodiac sign is by using cycle num as the index into our tuple called zodiac_animals. The ouput for this line of code should produce output like the sample execution above and given here output: Your Chinese zodiac sign is the Rooster -Then we print out the matching characteristics for that zodiac sign using cycle_num as the index into our tuple called characteristics. Your output should look like the output in the sample execution above and given here Your personal characteristics . .. Motivator, inquisitive, flexible, innovative, problem solver -Now, we want to prompt the user to see if they would like to enter another year and store it into the variable response while the user did not enter a lowercase y or 'n tell the user it was an invalid option -ask them again for a 'y' or 'n' -if the users response was a 'n' then we need to change our Boolean flag, terminate, to True. Now you should have a complete working program for the Chinese Zodiac. Make sure you save your file ram Modification: Modify the Chinese Zodiac program to allow the user to select either the Chinese Zodiac (C), the Japanese Zodiac (J), or the Vietnamese Zodiac (V). The Japanese Zodiac is the same as the Chinese Zodiac, except that 'Pig' is substituted with 'Wild Boar'.The Vietnamese Zodiac is also the same except that the 'Ox' is substituted with 'Water Buffalo' and 'Rabbit' is replaced with Cat' This program will display your Chinese, Japanese or vietnamese zodiac sign and associated personal characteristics. Enter (C)hinese, (J) apanese, or (V) ietnamese: J Enter your year of birth (yyyy) 1986 Your Chinese zodiac sign is the Tiger Your personal characteristics Unpredictable, rebellious,passionate, daring, impulsive Would you like to enter another year? (y):n I am going to give you a little guidance on how to modify your current program. 1) 2) Save your current file as modifiedZodiacyourlastname.py Your program should work exactly the same but you are just going to have to do some modifications in the initialization section, before the actual game play starts. Change your program greeting to match the new options the user can enter like in the prog execution above 3) This program will display your Chinese, Japanese or Vietnamese zodiac sign and associated personal characteristics. Right after the program greeting, we need to prompt the user for the zodiac_type Enter (C) hinese, (J) apanese, or (V) ietnamese:J 4) a. While the user doesn't enter a correct zodiac type ("C','J', or'V') i. ii. Tell the user it was an invalid option Ask the user again 5) Now we need to prep our program to handle the three different animal options a. We need to create three new variables to hold the three different animal types an initialize them to the original Chinese option for the Zodiac Animals i. ii. rabbit type - 'Rabbit' ox-type Ox, = iii. pigtype - 'Pig, - 6) Now that we have the three variables to hold our type, we need to update the types if the selects the Japanese zodiac or the Vietnamese Zodiac. a. If the user selects the Japanese zodiac i. Change the pig_type to be 'Wild Boar' b. Else if the user selects the Vietnamese zodiad i. ii. Change the ox_type to be the 'Water Buffalo' Change the rabbit_type to be the 'Cat' 7) Program should proceed as before 8) The final thing you should look at is inside the game play (in the while loop) In the print statement where you tell the user their zodiac sign, this should now say appropriate type based on zodiac_type, so the word Chinese could be either Japanese or Vietnamese a. Your Chinese zodiac sign is the Tiger oday We are 8oin8 to Step througn a prograrm Lnat deterrmines the animial and assoclated characteristics from the Chinese Zodiac for a given year of birth. This program is going to help with practice with tuples, while loops, if statements, booleans and introduce you to the datetime modu Here are two examples of what the program execution will look like when you are done writing th program Program Execution: This program will display your Chinese zodiac sign and associated personal characteristics Enter your year of birth (yyyy) 2004 Your Chinese zodiac sign is the Rooster Your personal characteristics Motivator, inquisitive, flexible, innovative, problem solver Would you like to enter another year? (y): 1986 Please enter 'y' or 'n': y Enter your year of birth (yyyy) 1986 Your Chinese zodiac sign is the Tiger Your personal characteristics Unpredictable, rebellious, passionate, daring, impulsive Would you like to enter another year? (y): n 3) The first thing we need to do is initialize our variables/tuples and import any modules that we will need. The datetime module supplies us with classes and functions that we can use to manipulate dates and times. To find out more about what is available when you import the datetime module you can check out the documentation at the following link https://docs.python.org/3.7/library/datetime.html. We will need to import the datetime module so that we get the current date and use it in our algorithm. a. import datetime b. The 12 animals of the Chinese Zodiac are the Rat, Ox, Tiger, Rabbit, Dragon, Snake, Horse, Goat, Monkey, Rooster, Dog, and Pig. Create a tuple of strings called zodiac animals that contains the 12 animals used in the Chinese Zodiac zodiac-animals Horse', Goat - ("Rat', 'Ox', 'Tiger', "Rabbit', 'Dragon', 'Monkey', 'RoosterDog','Pig') 'Snake ' , For each animal in the Chinese Zodiac there is a description of characteristics associated with that animal. For each animal, we are going to create a variable that holds the string of characteristics c. rat = 'Forthright, industrious, sensitive, intellectual, sociable' ox- "Dependable, methodical, modest, born leader, patient' tiger 'Unpredictable, rebellious, passionate, daring, impulsive' rabbit 'Good friend, kind, soft-spoken, cautious, artistic' dragonStrong, self-assured, proud, decisive, loyal' snake'Deep thinker, creative, responsible, calm, purposeful horse'Cheerful, quick-witted, perceptive, talkative, open-minded' goat-'Sincere, sympathetic, shy, generous, mothering monkey = "Motivator, inquisitive, flexible, innovative, problem solver rooster'Organized, self-assured, decisive, perfectionist, zealous dog -'Honest, unpretentious, idealistic, moralistic, easy going' pig 'Peace-1loving, hard-working,trusting, understanding, thoughtful' d. Now that we have variables for each animal that has been assigned to the string of characteristics, we are going to create a tuple of those representative variables. Createa tuple called characteristics that holds the string variables we just created characteristics-(rat, ox, tiger, rabbit, dragon, snake, horse, goat, monkey, rooster, dog, pig) Based on the program execution we saw above, we know that this program should continue running until the user tells us to terminate. We will need a Boolean variable to control a while loop we will create soon. For now, create a Boolean variable called terminate and assign it the value of False because we don't want to terminate the loop the first time we enter it. e. terminate False f. The next step is to print out the program greeting and let the user know the purpose of the program print ('This program will display your Chinese zodiac sign and associated') print ('personal characteristics. ') In order to figure out the users zodiac animal we are going to need to know the current year and rather than hardcoding in the current year. We are going to utilize the datetime module to get the year for us. I want you to create a variable called current_yr and assign it the value returned from the current year function, using dot notation to get to the appropriate property. The syntax to do this is as follows g. current_yrdatetime.date.today().year Now that we have initialized all of the data, we are now going to work on the control of the program. I provided you with the lines of code you needed, but for the next part I am going to provide you with the step by step algorithm and 90% of what you need. You will need to translate this algorithm into the appropriate syntax using the variables/tuples you created above and any variables Itell you to create in the algorithm Here is the algorithm for the functionality of the program while the user does not want to terminate the program prompt the user to enter the year of their birth, typecast it to an integer and store it in the variable birth_year.The result of this line of code should produce output like the sample execution above and given here output: Enter your year of birth (yyyy) while the user didn't enter a valid birth_year, which for the Chinese zodiac is anything less than 1900 and greater than the current year print a message telling them it was an invalid birth_year output: Invalid year. Please re-enter ask the user to enter the year of their birth, so you can check it again output: Enter your year of birth (yyyy) Now that the user has entered a valid input, we need to calculate what zodiac animal the user is and store it into a variable called cycle_ num. To find the cycle_num it is the (birth-year - 1900)812 Next, we print out a message to the user telling them what their Chinese Zodiac sign is by using cycle num as the index into our tuple called zodiac_animals. The ouput for this line of code should produce output like the sample execution above and given here output: Your Chinese zodiac sign is the Rooster -Then we print out the matching characteristics for that zodiac sign using cycle_num as the index into our tuple called characteristics. Your output should look like the output in the sample execution above and given here Your personal characteristics . .. Motivator, inquisitive, flexible, innovative, problem solver -Now, we want to prompt the user to see if they would like to enter another year and store it into the variable response while the user did not enter a lowercase y or 'n tell the user it was an invalid option -ask them again for a 'y' or 'n' -if the users response was a 'n' then we need to change our Boolean flag, terminate, to True. Now you should have a complete working program for the Chinese Zodiac. Make sure you save your file ram Modification: Modify the Chinese Zodiac program to allow the user to select either the Chinese Zodiac (C), the Japanese Zodiac (J), or the Vietnamese Zodiac (V). The Japanese Zodiac is the same as the Chinese Zodiac, except that 'Pig' is substituted with 'Wild Boar'.The Vietnamese Zodiac is also the same except that the 'Ox' is substituted with 'Water Buffalo' and 'Rabbit' is replaced with Cat' This program will display your Chinese, Japanese or vietnamese zodiac sign and associated personal characteristics. Enter (C)hinese, (J) apanese, or (V) ietnamese: J Enter your year of birth (yyyy) 1986 Your Chinese zodiac sign is the Tiger Your personal characteristics Unpredictable, rebellious,passionate, daring, impulsive Would you like to enter another year? (y):n I am going to give you a little guidance on how to modify your current program. 1) 2) Save your current file as modifiedZodiacyourlastname.py Your program should work exactly the same but you are just going to have to do some modifications in the initialization section, before the actual game play starts. Change your program greeting to match the new options the user can enter like in the prog execution above 3) This program will display your Chinese, Japanese or Vietnamese zodiac sign and associated personal characteristics. Right after the program greeting, we need to prompt the user for the zodiac_type Enter (C) hinese, (J) apanese, or (V) ietnamese:J 4) a. While the user doesn't enter a correct zodiac type ("C','J', or'V') i. ii. Tell the user it was an invalid option Ask the user again 5) Now we need to prep our program to handle the three different animal options a. We need to create three new variables to hold the three different animal types an initialize them to the original Chinese option for the Zodiac Animals i. ii. rabbit type - 'Rabbit' ox-type Ox, = iii. pigtype - 'Pig, - 6) Now that we have the three variables to hold our type, we need to update the types if the selects the Japanese zodiac or the Vietnamese Zodiac. a. If the user selects the Japanese zodiac i. Change the pig_type to be 'Wild Boar' b. Else if the user selects the Vietnamese zodiad i. ii. Change the ox_type to be the 'Water Buffalo' Change the rabbit_type to be the 'Cat' 7) Program should proceed as before 8) The final thing you should look at is inside the game play (in the while loop) In the print statement where you tell the user their zodiac sign, this should now say appropriate type based on zodiac_type, so the word Chinese could be either Japanese or Vietnamese a. Your Chinese zodiac sign is the Tiger

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!