def my_function(something):
#Do this with something
#Then do this
#Finally do this
def my_function():
result = 3 * 2
return result #return is a keyword for outputs
def format_name(f_name,l_name):
if f_name=="" or l_name=="":
return "You don't provide valid inputs"
formated_f_name = f_name.title()
formated_l_name = l_name.title()
return f"{formated_f_name} {formated_l_name}"
firstname = input("what is your first name?")
lastname = input("what is your last name?")
formated_string = format_name(firstname,lastname)
print(formated_string) #formated_string variable with return result by invoked format_name
day10-1-exercise.py (my code)
def is_leap(year):
if year%4==0 and year%100==0 and year%400==0:
return True
elif year%4==0 and year%100!=0:
return True
else:
return False
def days_in_month(year, month):
if not (month > 0 and month < 13):
return "Your input is invalid!"
month_days =[31,28,31,30,31,30,31,31,30,31,30,31]
if is_leap(year) and month==2:
return 29
return month_days[month-1]
leap_year = int(input("Please input Year to check leap year. "))
print(f"is leap year? {is_leap(leap_year)}")
year = int(input("Enter a year: "))
month = int(input("Enter a month: "))
days = days_in_month(year, month)
print(days)