Created
May 1, 2020 19:57
-
-
Save jonahaung/88a56693607c3ed5c4a07ed245ecd553 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Helper Functions | |
def clear_screen(): | |
print("") | |
print("") | |
print("") | |
print("") | |
# convert english calender year to Myanmar calender year | |
def convert_to_mm_year(year_int, is_born_before_new_year): | |
if is_born_before_new_year: | |
year_int -= 639 | |
else: | |
year_int -= 638 | |
return year_int | |
# name of the planet | |
def get_zodiac_name(zodiac_num): | |
if zodiac_num == 7 or zodiac_num == 0: | |
name = "Sunday" # Sun | |
elif zodiac_num == 1: | |
name = "Monday" # Mercury | |
elif zodiac_num == 2: | |
name = "Tuesday" # Saturn | |
elif zodiac_num == 3: | |
name = "Wednesday" # Mars | |
elif zodiac_num == 4: | |
name = "Thursday" # Venus | |
elif zodiac_num == 5: | |
name = "Friday" # Moon | |
elif zodiac_num == 6: | |
name = "Saturday" # Jupiter | |
else: | |
name = "Zodiac Name Error" | |
return name | |
def ask_eng_year(): | |
clear_screen() | |
user_input = input("- Please Enter Your Year of Birth") | |
try: | |
input_int = int(user_input) | |
is_valid_date = 1900 < input_int < 2020 # year must be between 1900 and 2020 | |
if is_valid_date: | |
return input_int | |
else: # if input year is not valid, recurse | |
return ask_eng_year() | |
except ValueError: # if input was not an integer, recurse | |
return ask_eng_year() | |
def ask_born_before_mm_newyear(): | |
clear_screen() | |
user_input = input("- Are you born on/before April 15 of the year? (Y/N)") | |
precondition = user_input == "Y" or user_input == "N" | |
if precondition: | |
return user_input == "Y" | |
else: | |
return ask_born_before_mm_newyear() # Recurse | |
def main(): | |
input("press Enter to start the program ....") | |
clear_screen() | |
eng_year = ask_eng_year() | |
is_before_new_year = ask_born_before_mm_newyear() | |
mm_year = convert_to_mm_year(eng_year, is_before_new_year) | |
zodiac_number = mm_year % 7 | |
zodiac_name = get_zodiac_name(zodiac_number) | |
result = \ | |
"Your were born on Myanmar year " + str(mm_year) + \ | |
"\nYour Burmese zodiac planet is " + zodiac_name + \ | |
"\nYour zodiac number is " + str(zodiac_number) | |
clear_screen() | |
print(result) | |
main() | |
# initial calling | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment