Created
April 30, 2020 06:54
-
-
Save kevinnls/049a46c1f51629fe5a2644edf2a1a920 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###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