Week 5 Flashcards

1
Q

What is a group of statements that exists within a program for the purpose of performing a specific task?
a. a function
b. a subtask
c. a process
d. a subprocess

A

a. a function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The first line in a function definition is known as the function
a. header
b. block
c. return
d. parameter

A

a. header

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The __________ design technique can be used to break down an algorithm into functions.
a. subtask
b. block
c. top-down
d. simplification

A

c. top-down

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A set of statements that belong together as a group and contribute to the function definition is known as a
a. header
b. block
c. return
d. parameter

A

b. block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A(n) __________ chart is also known as a structured chart.
a. flow
b. data
c. hierarchy
d. organizational

A

c. hierarchy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

A __________ variable is created inside a function.
a. global
b. constant
c. named constant
d. local

A

d. local

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The __________ of a local variable is the function in which that variable is created.
a. global reach
b. definition
c. space
d. scope

A

d. scope

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

A(n) __________ is any piece of data that is passed into a function when the function is called.
a. global variable
b. argument
c. local variable
d. parameter

A

b. argument

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A(n) __________ is a variable that receives an argument that is passed into a function.
a. global variable
b. argument
c. named constant
d. parameter

A

d. parameter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

A __________ variable is accessible to all the functions in a program file.
a. keyword
b. local
c. global
d. string

A

c. global

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

A __________ constant is a name that references a value that cannot be changed while the program runs.
a. keyword
b. local
c. global
d. string

A

c. global

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

When a function is called by its name during the execution of a program, then it is
a. executed
b. located
c. defined
d. exported

A

executed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

It is recommended that programmers avoid using __________ variables in a program whenever possible.
a. local
b. global
c. string
d. keyword

A

b. global

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

The Python library functions that are built into the Python __________ can be used by simply calling the required function.
a. code
b. compiler
c. linker
d. interpreter

A

d. interpreter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Python comes with __________ functions that have already been prewritten for the programmer.
a. standard
b. library
c. custom
d. key

A

b. library/standard???

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What type of function can be used to determine whether a number is even or odd?
a. even
b. odd
c. math
d. Boolean

A

d. Boolean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

A value-returning function is
a. a single statement that performs a specific task
b. called when you want the function to stop
c. a function that will return a value back to the part of the program that called it
d. a function that receives a value when called

A

c. a function that will return a value back to the part of the program that called it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Which of the following statements causes the interpreter to load the contents of the random module into memory?
a. load random
b. import random
c. upload random
d. download random

A

b. import random

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Which of the following will assign a random integer in the range of 1 through 50 to the variable number?
a. random(1, 50) = number
b. number = random.randint(1, 50)
c. randint(1, 50) = number
d. number = random(range(1, 50))

A

b. number = random.randint(1, 50)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What does the following statement mean?
num1, num2 = get_num()
a. The function get_num() is expected to return a value for num1 and for num2.
b. The function get_num() is expected to return one value and assign it to num1 and num2.
c. This statement will cause a syntax error.
d. The function get_num() will receive the values stored in num1 and num2.

A

a. The function get_num() is expected to return a value for num1 and for num2.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What will display after the following code is executed?
def main():
print(“The answer is”, magic(5))
def magic(num):
answer = num + 2 * 10
return answer
main()
a. 70
b. 25
c. 100
d. The statement will cause a syntax error.

A

b. 25

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

In a value-returning function, the value of the expression that follows the keyword __________ will be sent back to the part of the program that called the function.
a. def
b. result
c. sent
d. return

A

d. return

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

The Python standard library’s __________ module contains numerous functions that can be used in mathematical calculations.
a. math
b. string
c. random
d. number

A

a. math

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Which of the following functions returns the largest integer that is less than or equal to its argument?
a. floor
b. ceil
c. lesser
d. greater

A

a. floor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What will be the output after the following code is executed?
def pass_it(x, y):
z = x + “, “ + y
return(z)
name2 = “Tony”
name1 = “Gaddis”
fullname = pass_it(name1, name2)
print(fullname)

A

Gaddis, Tony

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What will be the output after the following code is executed?
def pass_it(x, y):
z = x , “, “ , y
num1 = 4
num2 = 8
answer = pass_it(num1, num2)
print(answer)

A

None

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

What will be the output after the following code is executed?
def pass_it(x, y):
z = y**x
return(z)
num1 = 3
num2 = 4
answer = pass_it(num1, num2)
print(answer)

A

64

28
Q

What will be displayed after the following code is executed?
def pass_it(x, y):
z = x*y
result = get_result(z)
return(result)
def get_result(number):
z = number + 2
return(z)
num1 = 3
num2 = 4
answer = pass_it(num1, num2)
print(answer)

A

14

29
Q

Python function names follow the same rules as those for naming variables.

A

True

30
Q

The function header marks the beginning of the function definition.

A

True

31
Q

A function definition specifies what a function does and causes the function to execute.

A

False

32
Q

A hierarchy chart shows all the steps that are taken inside a function.

A

False

33
Q

A local variable can be accessed from anywhere in the program.

A

False

34
Q

Different functions can have local variables with the same names.

A

True

35
Q

Python allows you to pass multiple arguments to a function.

A

Python

36
Q

To assign a value to a global variable in a function, the global variable must be first declared in the function.

A

True

37
Q

The value assigned to a global constant can be changed in the mainline logic.

A

False

38
Q

One reason not to use global variables is that it makes a program hard to debug.

A

True

39
Q

A value-returning function is like a simple function except that when it finishes it returns a value back to the part of the program that called it.

A

True

40
Q

Unlike other languages, in Python the number of values a function can return is limited to one.

A

False

41
Q

In Python you can have a list of variables on the left side of the argument operator.

A

True

42
Q

In Python there is no restriction on the name of a module file.

A

False

43
Q

One of the drawbacks of a modularized program is that the only structure you can use in such a program is the sequence structure.

A

False

44
Q

One reason to store graphics functions in a module is so that you can import the module into any program that needs to use those functions.

A

True

45
Q

The randrange function returns a randomly selected value from a specific sequence of numbers.

A

True

46
Q

The math function atan(x) returns one tangent of x in radians.

A

False

47
Q

The math function ceil(x) returns the smallest integer that is greater than or equal to x.

A

True

48
Q

The code for a function is known as a function ___________.

A

definition

49
Q

The function header begins with the keyword __________ and is followed by the name of the function.

A

def

50
Q

The main function contains a program’s __________ logic which is the overall logic of the program.

A

mainline

51
Q

In a flowchart, a function call is depicted by a(n) ___________.

A

rectangle

52
Q

The top-down design breaks down the overall task of a program into a series of __________.

A

subtasks

53
Q

A(n) __________ chart is a visual representation of the relationships between functions.

A

hierarchy

54
Q

Arguments are passed by __________ to the corresponding parameter variables in a function.

A

position

55
Q

A variable is available only to statements in the variable’s __________.

A

scope

56
Q

Functions that are in the standard library are stored in files that are known as __________.

A

modules

57
Q

To refer to a function in a module, Python uses ___________ notation.

A

dot

58
Q

A value-returning function has a(n) ___________ statement that sends a value back to the part of the program that called it.

A

return

59
Q

The ___________ chart is an effective tool used by programmers to design and document functions.

A

IPO

60
Q

The ‘P’ in the acronym IPO refers to ___________.

A

Processing

61
Q

In Python, a module’s file name should end in ___________.

A

.py

62
Q

The approach known as __________ makes a program easier to understand, test, and maintain.

A

Modularization

63
Q

The return values of the trigonometric functions in Python are in __________.

A

Radians

64
Q

The term _______________ is used to describe any mechanism that accepts input, performs some operation that cannot be seen, and produces output.

A

Black Box

65
Q

In a menu-driven program, a loop structure is used to determine the menu item the user selected.

A

False

66
Q

In a menu-driven program, a loop structure is used to determine the menu item the user selected.

A

False