Functions, Procedures, Arguments and Parameters
What does a constant do in relation to a value?
A constant replaces a value.
How is a procedure different than a function?
A procedure does not return a value, while a function does.
Which of the following is true of a procedure? Check all that apply.
It can be reused. It saves programmers time. It is a block of code that performs a single task.
Which of the following is true of a constant? Choose all that apply.
It cannot be changed by the program as it runs. It is a data type.
Which of the following are benefits of the Python programming language? Check all that apply.
It is free to use. It saves programmers time. It is relatively easy to learn.
Which of the following are advantages of using subroutines? Choose all that apply.
Subroutines allow the programmer to save time. Subroutines eliminate duplicate code.
Which of the following statements is true of subroutines? Check all that apply.
They can be used in multiple places. They save a programmer time since they are reusable. They can contribute to excessive use of a computer's resources.
Which of the following correctly defines a procedure in computer programming? Choose all the apply.
a code block that performs a single task a code block programmers can reuse multiple times
Which of the following correctly defines a function in computer programming? Choose all the apply.
a code block that performs a single task a code block that returns a value
A subroutine may be used to refer to which of the following? Check all that apply.
a function a subprogram a procedure a method
What is a special type of variable used in subroutines that refers to a piece of data?
a parameter
Which of the following defines code?
a set of instructions, written by a programmer, that is used by computers to perform tasks
What does a function return?
a value
This term, often used interchangeably with the term parameter, is the data that is passed into the parameter itself.
an argument
Which of the following describe a keyword argument? Check all that apply.
an argument in which the caller identifies it by parameter name an argument in which order of arguments does not matter
Which of the following describe a required argument? Check all that apply.
an argument passed to the function in the correct positional order an argument wherein the number of arguments in the function call should match the definition of the function
Which of the following describes a default argument?
an argument that does not need to be specified
Using the drop-down menu, complete the following questions based on your knowledge of variables. ___ is a value that can be used only from a block of code where it is declared. ___ is a storage location for a value. ___ is a value that can be called and used anywhere.
✔ A local variable ✔ A variable ✔ A global variable
Using the drop-down menu, complete these sentences about arguments. The ____ identifies the argument by parameter name. The _____ does not need to be specified in the function. A ___ is passed to a function in the correct positional order.
✔ keyword argument ✔ default argument ✔ required argument