Make it nicer
parent
3ff3822a40
commit
db6a714b5a
@ -1,11 +1,16 @@
|
||||
# In this example, I use def to define the function named (names_of_fruits),
|
||||
# the parameter is (fruits) and the argument is 'Apple'.
|
||||
# In this example, I use def to define the function named, i_love,
|
||||
# the parameter is fruits and the argument is 'Apple'.
|
||||
|
||||
def names_of_fruits(fruit): # first line of FUNCTION DEFINITION
|
||||
print("I love to eat %ss!" % fruit) # second line
|
||||
def i_love(fruit): # first line of FUNCTION DEFINITION
|
||||
print(f"I love to eat {fruit}s!") # second line
|
||||
|
||||
names_of_fruits('Apple') # FUNCTION CALL here!
|
||||
i_love('Apple') # FUNCTION CALL here!
|
||||
|
||||
|
||||
# Function calls have arguments, like 'Apple' here, and function definitions
|
||||
# have parameters,
|
||||
# have parameters. The parameter here is fruit. The argument is a *value*,
|
||||
# and the parameter is a *name*. Values are mapped to names, just like with
|
||||
# an assignment statement. It's the same as:
|
||||
#
|
||||
# fruit = 'Apple'
|
||||
#
|
||||
|
Loading…
Reference in New Issue