git_practice/homework06/functions/functions01.py
2025-12-14 18:34:36 -05:00

45 lines
912 B
Python

# Simple function examples
#No input parameters
def myFunction1():
print("You are in myFunction1")
# Two input patrameters
def myFunction2(x,y):
print("You are in myFunction2")
print("x = ",x)
print("y = ",y)
return(x + y)
# Two input parameters with predefined valiues.
# Provide one or no parameters. If not specified the default values will be used.
def myFunction3(x = 2,y = 3):
print("You are in myFunction3")
print("x = ",x)
print("y = ",y)
return(x + y)
# ======================== Main Program =============================
myFunction1()
retValue = myFunction2(3,4)
print(retValue)
retValue = myFunction2(5,6)
print(retValue)
# This generates an error
#retValue = myFunction2(4)
#print(retValue)
retValue = myFunction3(3,4)
print(retValue)
retValue = myFunction3(5)
print(retValue)
# This does not generate an error
retValue = myFunction3()
print(retValue)