Started Rectangle Project
This commit is contained in:
commit
26e1253c0d
39 changed files with 544 additions and 0 deletions
45
homework06/functions/functions01.py
Normal file
45
homework06/functions/functions01.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue