Menu

Functions

Card 1 of 18 0 got it 0 still learning
Question
TapClick or press space to see the answer
Answer
All 18 cards in this set
Which term describes a subprogram that may take parameters but does not return a value?
Procedure
Which term describes a value that is passed into a subprogram when it is called?
Argument
What is meant by a function?
A subprogram that returns a value to where it was called
What is meant by a parameter?
A named item in the definition of a subprogram that receives a value
Which term describes a variable that can only be used inside the subprogram where it is created?
Local variable
What is meant by the return value of a function?
The result that the function sends back to the point where it was called
Which of these statements about functions and procedures is correct?
A function must return a value but a procedure does not
A programmer writes a subprogram that takes a temperature in Celsius and sends back the value converted to Fahrenheit. What type of subprogram is this?
A function, because it returns a value
A program contains the line answer = sum(5, 3). What happens to the value returned by the sum function?
It is stored in the variable answer
Which of these is a function rather than a procedure?
random.randint(1, 6)
In the definition def showMenu():, what does showMenu represent?
The name given to the subprogram
A function is defined with the parameters a and b. What are a and b used for inside the function?
Holding the values that are passed in when the function is called
A function must work out the average of a total score and a number of attempts, then give the average back. Which statement must the function contain?
A return statement that sends back the average
Which of these is an advantage of using subprograms in a large program?
Each subprogram can be tested separately before it is used
Functions and procedures are both examples of which term?
Subprogram
A programmer writes def getDate(): so that it takes no values in but sends a date back when it is called. Which statement about getDate is correct?
It is a function because it returns a value
A menu is drawn by a subprogram that is called in several places in a program. When an extra menu option is needed, why does this help?
The menu code only has to be changed in one place
A program contains the line showMenu(). Which statement describes what happens when this line runs?
The code inside the showMenu subprogram is executed