csc 115 chapter 6
How does a function differ from a module?
A function performs a specific task; a module is a collection of functions.
What is a library function?
A pre-written function provided by a programming library.
Why are library functions like "black boxes"?
Because you use them without needing to know how they work internally.
This part of a function definition is comprised of one or more statements that are executed when the function is called. a. header b. footer c. body d. Return statement
C. body
In pseudocode, what does the statement "Set x = random(1, 100)" do?
It assigns a random number between 1 and 100 to the variable x.
What is the purpose of the Return statement in a function?
It ends the function and sends a value back to where the function was called.
What does "Display random(1, 20)" do in pseudocode?
It shows a random number between 1 and 20 on the screen
What is a Boolean function?
a function which returns either True or False.
Look at the following pseudocode function definition: Function Integer doSomething(Integer number) Return number * 2 End Function a. What is the name of the function? b. What type of data does the function return? c. Given the function definition, what will the following statement display? Display doSomething (10)
a. doSomething b. integer c. 20
This part of a function definition specifies the data type of the value that the function returns. a. header b. footer c. body d. Return statement
a. header
This is a string inside of another string. a. substring b. inner string c. mini string d. component string
a. substring
This type of error occurs when you try to assign a value of one data type to a variable of another data type. a. type mismatch error b. Boolean logic error c. relational error d. bit conversion error
a. type mismatch error
This is a design tool that describes the input, processing, and output of a function. a. hierarchy chart b. IPO chart c. datagram chart d. data processing chart
b. IPO chart
This is a prewritten function that is built into a programming language. a. standard function b. library function c. custom function d. cafeteria function
b. library function
This is an example of a data type conversion function in pseudocode. a. sqrt b. toReal c. substring d. isNumeric
b. toReal
This type of function returns either True or False. a. Binary b. TrueFalse c. Boolean d. logical
c. boolean
This term describes any mechanism that accepts input, performs some operation that cannot be seen on the input, and produces output. a. glass box b. white box c. opaque box d. black box
d. black box
In pseudocode, this statement causes a function to end and sends a value back to the part of the program that called the function. a. End b. Send c. Exit d. Return
d. return
In a case-sensitive comparison, the strings "yoda" and "YODA" are equivalent.
false
In some languages you must use a library function to raise a number to a power.
false
The code for a library function must appear in a program in order for the program to call the library function.
false
Complex mathematical expressions can sometimes be simplified by breaking out part of the expression and putting it in a function.
true
In many languages it is an error to assign a real number to an integer variable.
true