Randy J. Fortier
randy.fortier@uoit.ca
@randy_fortier
def sayHello():
print('Hello!')
sayHello()
def getAnswer():
return 42
answer = getAnswer()
def getDogAge(hAge):
return hAge * 7
answer1 = getDogAge(5)
humanAge = 7
answer2 = getDogAge(humanAge)
def getAgeInDogYears(humanAge):
"""
This function, given an age in human
years, returns the age in dog years.
"""
return humanAge * 7
def getAgeInDogYears(humanAge):
dogYearsFactor = 7 # local variable
return humanAge * dogYearsFactor
dogYearsFactor = 7 # global variable
def getAgeInDogYears(humanAge):
global dogYearsFactor
return humanAge * dogYearsFactor
def eightTimesTwo():
return 8 * 2
def timesTwo(num):
return num * 2
def timesTwo(num):
return num * 2
value = 8
print(timesTwo(value))