100 Days of Code - Function Parameters (Day8)

Function Parameters

1
2
3
4
5
6
7
# Function with inputs
# something is called parameter
def my_function(something(parameter)):
# Do this with something
print(f"Hello {something}")
# test is called argument, argument is the actual value of the data
my_function('test')

Fcunrion with more than one input

1
2
3
4
5
def greet_with(name, location):
print(f"Hello, {name}")
print(f"what is it like in {location}")

greet_with('Clayton','USA')

keyword argument

使用這種方式,就不用考慮傳入 argument 的順序

1
2
3
4
5
def greet_with(name, location):
print(f"Hello, {name}")
print(f"what is it like in {location}")

greet_with(location='USA',name='Clayton')