Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit f6ca789

Browse files
committed
Documentation: Add docstring in each module
1 parent 12b0bd5 commit f6ca789

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

projects/Calculate Age/src/calculate_age.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33

44

55
def age_calculator(name, age):
6+
"""
7+
Calculate user's age in years, month, and days
8+
based on current date and print.
9+
10+
Args:
11+
name (str): user's name.
12+
age (int): user's age in years.
13+
14+
Returns:
15+
None.
16+
"""
617
localtime = time.localtime(time.time())
718

819
year = int(age)

projects/Calculate Age/src/main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33

44
def main():
5+
"""
6+
the user to input name and age, validate input,
7+
and calculates and displays the user age in years, months and days.
8+
9+
Args:
10+
None.
11+
12+
Return:
13+
None.
14+
"""
515
input_name = input("input your name: ")
616

717
while True:

projects/Calculate Age/src/utilize_date.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,30 @@
22

33

44
def judge_leap_year(year):
5+
"""
6+
judge the leap year.
7+
8+
Args:
9+
year (int): To check the year.
10+
return:
11+
bool: Ture if the year is a leap year, False otherwise.
12+
"""
513
if isleap(year):
614
return True
715
else:
816
return False
917

1018

1119
def month_days(month, leap_year):
20+
"""
21+
Returns the number of days in each month
22+
23+
Args:
24+
month (int): The month 1-12.
25+
26+
Returns:
27+
int: The number of days in the month.
28+
"""
1229
if month in [1, 3, 5, 7, 8, 10, 12]:
1330
return 31
1431
elif month in [4, 6, 9, 11]:

0 commit comments

Comments
 (0)