Week 7-11 Flashcards
(195 cards)
3 advantages of Functions are:
1. Helps ________ code into blocks.
2. Makes program more ______________ and easier to update.
3. Can be reused, preventing _____________.
organize; readble; redundancy
____________ are written to complete a specific task.
Functions
What describes taking a complex set of instructions and packaging them together inside a block of code?
Functions
When using ‘def’ function, parentheses may contain optional ____________.
parameters
Is there a limit on the amount of lines of code that are in a function?
No
T/F: Functions can contain ANY valid python code.
T
“name” refers to the __________(parameter/argument) and “Taylor” refers to the ____________(parameter/argument).
parameter; argument
What is: the name of the data that we use inside of the function?
Parameter
Are there a limit of the number of parameters that can be used?
No
What is: data that is being passed to the function?
Argument
It is important to order the 2 ___________ the same as the 2 ________________.
arguments; parameters
In which type of argument does order matter?
Positional
Which argument does order not matter?
Keyword
What is the most basic type of argument in python?
Positional arguments
Positional arguments are passed to a function based on their ______________.
position/order
Keyword arguments allow you to pass arguments to a function using their _______________ __________.
Parameter names
Which argument is specified by key-value pairs and are separated by commas?
Keyword Arguments
Which argument makes code more self-explanatory?
Keyword arguments
Which argument is the longest?
Keyword
my_first_function(a=1, b=2, c=3) is an example of what?
Keyword Argument
Where is a local scope defined?
Inside a function
Which scope cannot be accessed outside of a function?
Local scope
Def greet():
-message = “Hello World!”
-Print(message)
What is the local variable?
Hello World!
What would be printed in the following:
Def funcB(a,b):
-A = 2
-B = 3
-Print(“Inside funcB a,b = “, a,b)
2,3