From f3494b5332c154fccf6358802efcef2bb7cd75f2 Mon Sep 17 00:00:00 2001 From: marcusvel28 Date: Mon, 12 Aug 2024 14:15:26 -0400 Subject: [PATCH 1/3] The Zodiacs are findable --- problem_set/Q2_Chinese_Zodiac.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/problem_set/Q2_Chinese_Zodiac.py b/problem_set/Q2_Chinese_Zodiac.py index 010f431..c4ae78a 100644 --- a/problem_set/Q2_Chinese_Zodiac.py +++ b/problem_set/Q2_Chinese_Zodiac.py @@ -10,4 +10,22 @@ # write a function that takes the year as the input and produces the Zodiac for that year # output should be in the format "2000 is the year of the Fire Rat" +chinese_dict= { + 'animals': ["Rat","Ox","Tiger","Rabbit","Dragon","Snake","Horse","Goat","Monkey","Rooster","Dog","Pig"], + 'elements': ["Fire", "Earth", "Metal", "Water", "Wood"] +} +year=2000 +def chinese_new_year(x): + x = int(x) + year = (x-2000) % 60 + result=[] + for element in chinese_dict["elements"]: + for animal in chinese_dict["animals"]: + order = f"{element} {animal}" + result.append(order) + Zodiac = result[year] + Messege= f"{x} is the year of the {Zodiac}" + return Messege +Zodiac = chinese_new_year(2000) +print(Zodiac) \ No newline at end of file From 2e6a6f935b38a317e008d219ba3d58da1b57ef72 Mon Sep 17 00:00:00 2001 From: marcusvel28 Date: Mon, 12 Aug 2024 15:15:49 -0400 Subject: [PATCH 2/3] final --- problem_set/Q2_Chinese_Zodiac.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/problem_set/Q2_Chinese_Zodiac.py b/problem_set/Q2_Chinese_Zodiac.py index c4ae78a..7b5c7a9 100644 --- a/problem_set/Q2_Chinese_Zodiac.py +++ b/problem_set/Q2_Chinese_Zodiac.py @@ -17,15 +17,18 @@ year=2000 def chinese_new_year(x): x = int(x) - year = (x-2000) % 60 + year = (x-2024) % 60 result=[] for element in chinese_dict["elements"]: for animal in chinese_dict["animals"]: order = f"{element} {animal}" result.append(order) Zodiac = result[year] - Messege= f"{x} is the year of the {Zodiac}" + if x<2024: + Messege = f"{x} was the year of the {Zodiac}" + else: + Messege = f"{x} is the year of the {Zodiac}" return Messege -Zodiac = chinese_new_year(2000) +Zodiac = chinese_new_year(input("Input a year to determine it's associated Zodiac: ")) print(Zodiac) \ No newline at end of file From 1958886be8348e660895958fd383048bd5519e4b Mon Sep 17 00:00:00 2001 From: marcusvel28 Date: Fri, 16 Aug 2024 11:51:28 -0400 Subject: [PATCH 3/3] Finialized Q2 Push --- problem_set/Q2_Chinese_Zodiac.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/problem_set/Q2_Chinese_Zodiac.py b/problem_set/Q2_Chinese_Zodiac.py index 7b5c7a9..e0afc50 100644 --- a/problem_set/Q2_Chinese_Zodiac.py +++ b/problem_set/Q2_Chinese_Zodiac.py @@ -16,8 +16,14 @@ } year=2000 def chinese_new_year(x): + """ + Takes a inputted year, and output what Chinese Zodiac is for that year + """ x = int(x) + # Initialized for 2024 and cycles through the total 60 states the Zodiac may be. + ## It is aligned with the index numbers of the list year = (x-2024) % 60 + result=[] for element in chinese_dict["elements"]: for animal in chinese_dict["animals"]: