Example of making a function
This commit is contained in:
parent
ff70d33774
commit
6309dca815
18
Python/027_function.py
Normal file
18
Python/027_function.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# A simple example of making a function
|
||||
|
||||
# Functions are blocks of code that can be
|
||||
# called/referenced from elsewhere in the code.
|
||||
# This can be useful if we need to do some common
|
||||
# operation from multiple places. That way we
|
||||
# compartmentalize the logic in one place and only
|
||||
# have one place that needs edited if the logic must
|
||||
# be changed at a later date.
|
||||
|
||||
def you_baby(name):
|
||||
return name + "baby McBabyface"
|
||||
|
||||
your_name = None
|
||||
while your_name != "":
|
||||
your_name = input("What is your first name (hit <Enter> to quit): ")
|
||||
if your_name != "":
|
||||
print("Your name is", you_baby(your_name))
|
Loading…
Reference in New Issue
Block a user