diff --git a/Age Calculator.py b/AgeCalculator.py similarity index 96% rename from Age Calculator.py rename to AgeCalculator.py index af545f45..a4665759 100644 --- a/Age Calculator.py +++ b/AgeCalculator.py @@ -1,24 +1,24 @@ -# Calculate the complete age of a person in years, months and days - -import datetime - -def calculate_age(born): - today = datetime.date.today() - return today.year - born.year - ((today.month, today.day) < (born.month, born.day)) - -def main(): - - # Get the date of birth - dob = input("Enter your date of birth (YYYY-MM-DD): ") - - # Split the date into year, month and day - year, month, day = map(int, dob.split('-')) - - # Calculate the age - age = calculate_age(datetime.date(year, month, day)) - - # Print the age - print("Your age is: {}".format(age)) - -if __name__ == '__main__': +# Calculate the complete age of a person in years, months and days + +import datetime + +def calculate_age(born): + today = datetime.date.today() + return today.year - born.year - ((today.month, today.day) < (born.month, born.day)) + +def main(): + + # Get the date of birth + dob = input("Enter your date of birth (YYYY-MM-DD): ") + + # Split the date into year, month and day + year, month, day = map(int, dob.split('-')) + + # Calculate the age + age = calculate_age(datetime.date(year, month, day)) + + # Print the age + print("Your age is: {}".format(age)) + +if __name__ == '__main__': main() \ No newline at end of file