| Python 首頁 | Data Type |
def func_name(parameter)
def check_leap_year(year):
if (year % 400 == 0) or (year % 100 != 0 and year % 4 == 0):
print("閏年")
else:
print("平年")
year = int(input())
check_leap_year(year)
def check_leap_year(year):
if (year % 400 == 0) or (year % 100 != 0 and year % 4 == 0):
return "閏年"
else:
return "平年"
year = int(input())
ret = check_leap_year(year)
print(ret)
def check_leap_year(year):
if (year % 400 == 0) or (year % 100 != 0 and year % 4 == 0):
return True, "閏年"
else:
return False, "平年"
year = int(input())
is_leap, ret = check_leap_year(year)
print(is_leap)
print(ret)
def factorial_loop(n):
factor = 1
for i in range(1,n+1):
factor *= i
return factor
print(factorial_loop(3))
def factorial(n):
if n == 0 or n == 1:
return 1
else:
return n * factorial(n - 1)
print(factorial(3))