Created
January 14, 2025 08:07
-
-
Save Bilalshaikh15/9d975c8b2bc9e603155589d29f147890 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
age = int(input("")) | |
dob = input("") | |
dobString = dob.split("/") | |
day, month, year = int(dobString[0]), int(dobString[1]), int(dobString[2]) | |
# just add 5 in the current year | |
fifth_birthday = f"{day}/{month}/{year+5}" | |
# add current age to current year | |
last_birthday = f"{day}/{month}/{year+age}" | |
# if month is greater than 12 then increase the year and subtract the remaining | |
tenth_month = month + 10 | |
if (tenth_month > 12): | |
tenth_month = tenth_month - 12 | |
year = year + 1 | |
after_tenth_month_dob = f"{day}/{tenth_month}/{year}" | |
print(f"{after_tenth_month_dob}, {fifth_birthday}, {last_birthday}") | |
# for weight progarm it would be a simple code by taking string as an input then splitting it based on "." (weight.split(".")) then extracting | |
# kg and grams and converting that to integer or float but with this the precision problem occurrs so that is why, I did it this way. | |
# kg,gram = weight.split(".") # str: reformat weight of format 55 kg 250 grams | |
weight = float(input("")) | |
kg, grams = repr(format(weight, '.3f')).replace("'","").split(".") | |
print(f"{kg} kg {grams} grams") | |
# By Bilal Shaikh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment