Skip to content

Instantly share code, notes, and snippets.

@kevinnls
Created April 30, 2020 06:54
Show Gist options
  • Save kevinnls/049a46c1f51629fe5a2644edf2a1a920 to your computer and use it in GitHub Desktop.
Save kevinnls/049a46c1f51629fe5a2644edf2a1a920 to your computer and use it in GitHub Desktop.
###GLOBAL SECTION###
current_year = 2020
###FUNCTION DEF###
def age_finder(parameter): #get the parameter from function call (ln.16) and save in *parameter*
dob = parameter.split("/")
yob = int(dob[2])
result = current_year - yob #calculate result
return result #return *result* to funciton call (ln.14)
####MAIN###
name = "Epoch" #create var called name
dob = "01/01/1970" #create var called dob in format dd/mm/yyyy
# call the function *age_finder()*
# passing value of *dob* as parameter
# save the result of the function in the variable age
age = age_finder(dob)
# print everything
print(f"Age of {name} born on {dob} is {age} in the year {current_year}.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment