Chapter 2 Input, Processing, and Output 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

logic

Chapter 2 (page 32)

A logic error is a mistake that does not prevent the program from running, but causes it to produce incorrect results. (Mathematical mistakes are common causes of logic errors.)

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

software requirement

Chapter 2 (page 33)

A software requirement is simply a single task that the programmer must perform in order to satisfy the customer. Once the customer agrees that the list of requirements is complete, the programmer can move to the next phase.

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

algorithm

Chapter 2 (page 33)

An algorithm is a set of well-defined logical steps that must be taken to perform a task. Steps in algorithm are sequentially ordered, step 1 should be performed before step 2, and so on.

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

Chapter 2 (page 34)

Word “pseudo” means fake, so pseudocode is fake code. It is an informal language that has no syntax rules and is not meant to be compiled or executed. Programmers use pseudocode to create models, or “mock-ups” of programs.

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

flowchart

Chapter 2 (page 34)

A flowchart is a diagram that graphically depicts the steps that take place 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

string

Chapter 2 (page 37)

In programming terms, a sequence of characters that is used as data is called string. When a string appears in the actual code of a program, it is called a string literal. In Python code, string literals must be enclosed in quote marks.

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

variable

Chapter 2 (page 40)

A variable is a name that represents a value in the computer’s memory. For example, a program that calculates the sales tax on a purchase might use the variable name ‘tax’ to represent that value in memory.
When a variable represents a value in the computer’s memory, we say that the variable ‘references’ the 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

Chapter 2 (page )

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

either single quotes or double quotes

Chapter 2 (page 37)

In Python, you can enclose string literals in a set of single-quote marks ( ‘ ) or a set of double-quote marks ( “ )

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

Chapter 2 (page 39)

Comments are short notes placed in different parts of a program, explaining how those parts of the program work. Although comments are a critical part of a program, they are ignored by the Python interpreter. Comments are intended for any person reading a program’s code, not the computer.

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

assignment statement

Chapter 2 (page 40)

You use an assignment statement to create a variable and make it reference a piece of data. Here is an example of an assignment statement:
age = 25

An assignment statement is written in the following general format:
variable = expression

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

#

Chapter 2 (page 39)

In Python, you begin a comment with the # character. When the Python interpreter sees a # character, it ignores everything from that character to the end of the line.

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 = 99999
d. x = ‘ 17 ‘

A

17 = x

Chapter 2 (page 42)

In an assignment statement, the variable that is receiving the assignment must appear on the left side of the operator. An error occurs if the item on the left side of the = operator is not a variable

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

Chapter 2 (page)

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

/ /

Chapter 2 (page 54)

/ / Integer Division
Divides one number by another and gives the result as a whole number.
5 // 2 = 2

/ Division
Divides one number by another and gives the result as a floating-point number.
5 / 2 = 2.5

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
  • *

Chapter 2 (page 54)

** Exponent
Raises a number to a power.

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

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

a. %
b. *
c. **
d. /

A

%

Chapter 2 (page 54)

% Remainder
Divides one number by another and gives the remainder.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

float

Chapter 2 (page 47)

A numeric literal that is written with a decimal point is considered a float. Examples are 1.5, 3.14159 , and 99.0

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 ( )

Chapter 2 (page 49)

The input function reads a piece of data that has been entered at the keyboard and returns that piece of data, as a string, back to the program. You normally use the input function in an assignment statement that follows this general format:
variable = input(prompt)

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

int ( )

Chapter 2 (page 51)
int(item)
You pass an argument to the int( ) function and it returns the argument's value converted to an int.
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 a computer to crash

A

an unexplained value that appears in a program’s code

Chapter 2 (page 73)

A magic numbers can be problematic, for a number of reasons. It can be difficult for someone reading the code to determine the purpose of of the number. If the magic number is used in multiple places in the program, it can take painstaking effort to change the number in each location should the need arise. Third, you take the risk of making a typographical mistake each time you type the magic number in the 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

named constant

Chapter 2 (page 73)

23
Q

Programmers must be careful not to make syntax errors when writing pseudocode programs. True or False?

A

False

Chapter 2 (page 34)

Programmers use pseudocode to create models, or “mock-ups” of programs. Programmers don’t have to worry about syntax errors while writing pseudocode, they can focus all of their attention on the program’s design.

24
Q

In a math expression, multiplication and division take place before addition and subtraction. True or False?

A

Chapter 2 (page )

25
Q

Variable names can have spaces in them. True or False?

A

False

Chapter 2 (page 43)

A variable name cannot contain spaces

26
Q

In Python, the first character of a variable name cannot be a number. True or False?

A

True

Chapter 2 (page 43)

The first character must be one of the letters a through z, A through Z, or an underscore character ( _ ).

27
Q

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

A

Chapter 2 (page )

28
Q

Select all that apply. Which of the following are steps in the program development cycle?

a. write the code and correct syntax errors
b. design the program
c. test the program
d. correct logic errors

A

All of the above

Chapter 2 Q

29
Q

Which mathematical operator is used to raise 5 to the second power in Python?

a. /
b. ~
c. ^
d. **

A
  • *

Chapter 2 Q

30
Q

A flowchart is a tool used by programmers to design programs.
True or False?

A

True

Chapter 2 Q

31
Q

The \t escape character causes the output to skip over to the next horizontal tab.
True or False?

A

True

Chapter 2 Q

32
Q

The Python turtle is initially positioned in the ___ of a graphics window and it first appears, by devault to be heading ___.

a. bottom left corner, down
b. top left corner, east
c. center, east
d. center, up

A

center, east

Chapter 2 Q

33
Q

Since a named constant is just a variable, it can change any time during a program’s execution.
True or False?

A

False

Chapter 2 Q (page# 73)

A named constant is a name that represent a value that cannot be changed during the program’s execution.

34
Q

Comments in Python begin with the # character.

True or False?

A

True

Chapter 2 Q

35
Q

The ___ build-in function is used to read a number that has been typed on the keyboard.

a. keyboard()
b. read()
c. input()
d. get()

A

input()

Chapter 2 Q

36
Q

Python allows programmers to break a statement into multiple lines.
True or False?

A

True

Chapter 2 Q

37
Q

What symbol is used to mark the beginning and end of a string?

a. a quote mark ( “ )
b. an asterisk ( * )
c. a slash ( / )
d. a comma ( , )

A

a quote mark (“)

Chapter 2 Q

38
Q

When using the camelCase naming convention, the first word of the variable name is written in lowercase and the first characters of all subsequent words are written in uppercase.
True or False?

A

True

Chapter 2 Q

39
Q

Select all that apply. Assume you are writing a program that calculates a user’s total order cost that includes sales tax of 6.5%. Which of the following are advantages of using a named constant to represent the sales tax instead of simply entering 0.065 each time the tax is required in the code?

a. It avoids the risk that any change to the value of sales tax will be made incorrectly or that an instance of the tax value might be missed as might occur if the number had to be changed in multiple locations.
b. It allows the end-user to always see the value of the sales tax.
c. It will be easier for another programmer who may need to use this code to understand the purpose of the number wherever it is used in the code.
d. If the tax amount changes to 7.0%, the value will only have to changed in one place.

A

A
C
D

Chapter 2 Q

40
Q

The line continuation character is a

a. #
b. &
c. \
d. %

A

\

Chapter 2 Q

41
Q

A(n) ___ is a diagram that graphically depicts the steps that take place in a program?

a. pseudocode
b. source code
c. algorithm
d. flowchart

A

flowchart

Chapter 2 Q

42
Q

In Python print statements written on separate lines do not necessarily output on separate lines.
True or False?

A

True

Chapter 2 Q

43
Q

In a print statement, you can set the ___ argument to a space or empty string to stop the output from advancing to a new line.

a. stop
b. end
c. separator
d. newLine

A

end

Chapter 2 Q