Chapter 2 Multiple choice questions Flashcards

1
Q

A ______ error does not prevent the program from running, but causes it to produce incorrect results.

a) syntax
b) hardware
c) logic
d) fatal

A

A logic error – code written with correct syntax but needs debugging because it does not do what was intended.

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

A ______ is a single function that the program must perform in order to satisfy the customer.

a) task
b) software requirement
c) prerequisite
d) predicate

A

A software requirement is a single function that the program must perform in order to satisfy the customer.

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

A(n) ______ is a set of well-defined logical steps that must be taken to perform a task.

a) logarithm
b) plan of action
c) logic schedule
d) algorithm

A

An algorithm

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

An informal language that has no syntax rules and is not meant to be compiled or executed is called ______.

a) faux code
b) pseudocode
c) Python
d) a flowchart

A

Pseudocode is an informal language that has no syntax rules.

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

A ______ is a diagram that graphically depicts the steps that take place in a program.

a) flowchart
b) step chart
c) code graph
d) program graph

A

A flowchart graphically depicts the steps that happen in a program.

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

A ______ is a sequence of characters.

a) char sequence
b) character collection
c) string
d) text block

A

A sequence of characters is called a string.

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

A ______ is a name that references a value in the computer’s memory.

a) variable
b) register
c) RAM slot
d) byte

A

A variable is a name that references a value

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

A ______ is any hypothetical person using a program and providing input for it.

a) designer
b) user
c) guinea pig
d) test subject

A

A user

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

A string literal in Python must be enclosed in ______.

a) parentheses
b) single-quotes
c) double-quotes
d) either single-quotes or double-quotes

A

A string literal must be enclosed in either single-quotes or double-quotes.

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

Short notes placed in different parts of a program explaining how those parts of the program work are called

a) comments
b) reference manuals
c) tutorials
d) external documentation

A

Comments.

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

A(n) ______ makes a variable reference a value in the computer’s memory.

a) variable declaration
b) assignment statement
c) math expression
d) string literal

A

A variable declaration.

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

This symbol marks the beginning of a comment in Python.

a) &
b) *
c) **
d) #

A

marks the beginning of a comment in Python.

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

Which of the following statements will cause an error?

a) x = 17
b) 17 = x
c) x = 9999
d) x = ‘17’

A

17 = x

A variable must be declared on the left, and variable names cannot begin with numbers.

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

In the expression 12 + 7, the values on the right and left of the + symbol are called ______.

a) operands
b) operators
c) arguments
d) math expressions

A

-The values on the left and right of the operator (+) are called operands.

(The full equation, 12 + 7, is called a math expression.)

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

This operator performs integer division.

a) //
b) &
c) **
d) /

A

/

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

This is an operator that raises a number to a power.

a) %
b) *
c) **
d) /

A

**

17
Q

This operator performs division, but instead of returning the quotient it returns the remainder.

a) %
b) *
c) **
d) /

A

%

18
Q

Suppose the following statement is in a program:
price = 99.0

After this statement executes, the price variable will reference a value of which data type?

a) int
b) float
c) currency
d) str

A

A float (it contains decimals).

19
Q

Which built-in function can be used to read input that has been typed on the keyboard?

a) input()
b) get_input()
c) read_input()
d) keyboard()

A

input()

20
Q

Which built-in function can be used to convert an int value to a float?

a) int_to_float()
b) float()
c) convert()
d) int()

A

float()

21
Q

A magic number is ______.

a) a number that is mathematically undefined
b) an unexplained value that appears in a program’s code
c) a number that cannot be divided by 1
d) a number that causes computers to crash

A

A magic number is an unexplained value that appears in a program’s code.

22
Q

A ______ is a name that represents a value that does not change during the program’s execution.

a) named literal
b) named constant
c) variable signature
d) key term

A

A named constant represents a value that does not change during the program’s execution.

23
Q

True or false:

Programmers must be careful not to make syntax errors when writing pseudocode programs.

A

False. Pseudocode is never actually run, it is meant to help think through how to code.

24
Q

True or false:

In a math expression, multiplication and division take place before addition and subtraction.

A

True, multiplication and division take place before addition and subtraction.

25
Q

True or false:

Variable names can have spaces in them.

A

False, variable names can only contain A-Z, a-z, 0-9 and _

26
Q

True or false:

In Python, the first character of a variable name cannot be a number.

A

True, the first character of a variable name cannot be a number in Python.

27
Q

If you print a variable that has not been assigned a value, the number 0 will be displayed.

A

False, it does not contain 0 and is considered NULL.