Functions and Modules: Difference between revisions
Appearance
Created page with " <syntaxhighlight lang="python" line> def make_shirt(size = "L", slogan = "I love Python"): # two params both with default values """Generate a T-shirt order with size and slogan """ # for documentation of function purpose print(f"\nYou ordered a T-shirt saying '{slogan}' in size {size}.\n") make_shirt() # call with defaults make_shirt("M")..." |
(No difference)
|
Revision as of 16:59, 4 April 2024
def make_shirt(size = "L", slogan = "I love Python"): # two params both with default values
"""Generate a T-shirt order with size and slogan """ # for documentation of function purpose
print(f"\nYou ordered a T-shirt saying '{slogan}' in size {size}.\n")
make_shirt() # call with defaults
make_shirt("M") # call with size only
make_shirt(slogan = "I like Python") # call with slogan only (must specify param name)
make_shirt(size = "S", slogan = "I like Python") # call with both size and slogan