Quizzes Flashcards

1
Q

T/F: A software developer is the person with the training to design, create, and test computer programs.

A

True

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

T/F: All programs are normally stored in ROM and are loaded into RAM as needed for processing.

A

False

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

T/F: The CPU understands instructions written in a binary machine language.

A

True

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

T/F: The main reason to use secondary storage is to hold data for long periods of time, even when the power supply to the computer is turned off.

A

True

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

T/F: RAM is a volatile memory used for temporary storage while a program is running.

A

True

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

T/F: The Python language uses a compiler which is a program that both translates and executes the instructions in a high-level language.

A

False

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

T/F: IDLE is an alternative method to using a text editor to write, execute, and test a Python program.

A

True

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

Programs are commonly referred to as

A

software

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

Where does a computer store a program and the data that the program is working with while the program is running?

A

in main memory

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

Which computer language uses short words known as mnemonics for writing programs?

A

Assembly

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

The process known as the __________ cycle is used by the CPU to execute instructions in a program.

A

fetch-decode-execute

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

The __________ coding scheme contains a set of 128 numeric codes that are used to represent characters in the computer’s memory.

A

ASCII

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

The disk drive is a secondary storage device that stores data by __________ encoding it onto a spinning circular disk.

A

magnetically

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

What is the decimal value of the following binary number?

10011101

A

157

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

What is the largest value that can be stored in one byte?

A

255

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

T/F: Comments in Python begin with the # character.

A

True

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

T/F: 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.

A

True

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

T/F: According to the behavior of integer division, when an integer is divided by an integer, the result will be a float.

A

False

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

T/F: Python formats all floating-point numbers to two decimal places when outputting with the print statement.

A

False

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

T/F: A flowchart is a tool used by programmers to design programs.

A

True

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

T/F: In Python, math expressions are always evaluated from left to right, no matter what the operators are.

A

False

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

T/F: Computer programs typically perform three steps: input is received, some process is performed on the input, and output is produced.

A

True

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

What is the informal language, used by programmers use to create models of programs, that has no syntax rules and is not meant to be compiled or executed?

A

pseudocode

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

The __________ 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.

A

input()

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

end

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

After the execution of the following statement, the variable sold will reference the numeric literal value as (n) __________ data type.

sold = 256.752

A

float

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

After the execution of the following statement, the variable price will reference the value __________.

price = int(68.549)

A

68

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

What is the output of the following code?

val = 123.456789

print(f’{val:.3f}’)

A

123.457

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

Which of the following will display 20%?

  • print(f’{20:.0%}’)
  • print(f’{0.2:.0%}’)
  • print(f’{0.2 * 100:.0%}’)
  • print(f’{0.2:%}’)
A

print(f’{0.2:.0%}’)

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

What is the output of the following statement, given that value1 = 2.0 and value2 = 12?

print(value1 * value2)

  • 24
  • value1 * value2
  • 24.0
  • 2.0 * 12
A

24.0

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

T/F: The Python language is not sensitive to block structuring of code.

A

False

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

T/F: The if statement causes one or more statements to execute only when a Boolean expression is true.

A

True

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

T/F: Python allows you to compare strings, but it is not case sensitive.

A

False

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

T/F: Nested decision statements are one way to test more than one condition.

A

True

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

T/F: Python uses the same symbols for the assignment operator as for the equality operator.

A

False

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

T/F: Expressions that are tested by the if statement are called Boolean expressions.

A

True

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

T/F: Decision structures are also known as selection structures.

A

True

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

A(n) __________ structure is a logical design that controls the order in which a set of statements execute.

A

control

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

Multiple Boolean expressions can be combined by using a logical operator to create __________ expressions.

A

compound

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

When using the __________ logical operator, one or both of the subexpressions must be true for the compound expression to be true.

A

or

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

A Boolean variable can reference one of two values which are

A

True or False

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

What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8?

x < y or z > x

A

True

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

What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8?

x < y and z > x

A

False

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

In Python the __________ symbol is used as the not-equal-to operator.

A

!=

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

In Python the __________ symbol is used as the equality operator.

A

==

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

T/F: Reducing duplication of code is one of the advantages of using a loop structure.

A

True

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

T/F: A good way to repeatedly perform an operation is to write the statements for the task once and then place the statements in a loop that will repeat as many times as necessary.

A

True

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

T/F: In Python, an infinite loop usually occurs when the computer accesses an incorrect memory address.

A

False

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

T/F: Both of the following for clauses would generate the same number of loop iterations.

for num in range(4):

for num in range(1, 5):

A

True

50
Q

T/F: In a nested loop, the inner loop goes through all of its iterations for each iteration of the outer loop.

A

True

51
Q

T/F: A while loop is called a pretest loop because the condition is tested after the loop has had one iteration.

A

False

52
Q

T/F: The integrity of a program’s output is only as good as the integrity of its input. For this reason, the program should discard input that is invalid and prompt the user to enter valid data.

A

True

53
Q

What type of loop structure repeats the code a specific number of times?

A

count-controlled loop

54
Q

What are the values that the variable num contains through the iterations of the following for loop?

for num in range(2, 9, 2):

A

2,4,6,8

55
Q

A variable used to keep a running total is called a(n)

A

accumulator

56
Q

A(n) __________ structure is a structure that causes a statement or a set of statements to execute repeatedly.

A

repetition

57
Q

In Python, a comma-separated sequence of data items that are enclosed in a set of brackets is called

A

list

58
Q

In Python, the variable in the for clause is referred to as the __________ because it is the target of an assignment at the beginning of each loop iteration.

A

target variable

59
Q

The first operation is called the __________ and its purpose is to get the first input value that will be tested by the validation loop.

A

priming read

60
Q

When will the following loop terminate?

while keep_going != 999:

A

when keep_going refers to a value equal to 999

61
Q

Which of the following is associated with a specific file and provides a way for the program to work with that file?

  • filename
  • file extension
  • file object
  • file variable
A

file object

62
Q

Which of the following describes what happens when a piece of data is written to a file?

  • The data is copied from a variable in RAM to a file.
  • The data is copied from a variable in the program to a file.
  • The data is copied from the program to a file.
  • The data is copied from a file object to a file.
A

The data is copied from a variable in RAM to a file.

63
Q

Which step creates a connection between a file and a program?

A

Open the file

64
Q

A(n) __________ access file is also known as a direct access file.

A

random

65
Q

A single piece of data within a record is called a

A

field

66
Q

Which mode specifier will erase the contents of a file if it already exists and create the file if it does not already exist?

A

w

67
Q

Which mode specifier will open a file but not let you change the file or write to it?

A

r

68
Q

Which method could be used to convert a numeric value to a string?

A

str

69
Q

Which method will return an empty string when it has attempted to read beyond the end of a file?

A

readline

70
Q

Which statement can be used to handle some of the runtime errors in a program?

A

a try/except statement

71
Q

Given that the customer file references a file object, and the file was opened using the ‘w’ mode specifier, how would you write the string ‘Mary Smith’ to the file?

A

customer.write(“Mary Smith”)

72
Q

T/F: If a file with the specified name already exists when the file is opened and the file is opened in ‘w’ mode, then an alert will appear on the screen.

A

False

73
Q

T/F: Closing a file disconnects the communication between the file and the program.

A

True

74
Q

T/F: The ZeroDivisionError exception is raised when the program attempts to perform the calculation x/y if y = 0.

A

True

75
Q

T/F: Strings can be written directly to a file with the write method, but numbers must be converted to strings before they can be written.

A

True

76
Q

T/F: The function header marks the beginning of the function definition.

A

True

77
Q

T/F: A local variable can be accessed from anywhere in the program.

A

False

78
Q

T/F: Python allows you to pass multiple arguments to a function.

A

True

79
Q

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

A

True

80
Q

T/F: 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

81
Q

T/F: 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

82
Q

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

A

True

83
Q

What is a group of statements that exists within a program for the purpose of performing a specific task?

A

function

84
Q

A set of statements that belong together as a group and contribute to the function definition is known as a

A

block

85
Q

The _____________ keyword is ignored by the Python interpreter and can be used as a placeholder for code that will be written later.

A

pass

86
Q

The __________ of a local variable is the function in which that variable is created.

A

scope

87
Q

A(n) __________ is any piece of data that is passed into a function when the function is called.

A

argument

88
Q

When a function is called by its name during the execution of a program, then it is

A

executed

89
Q

The Python library functions that are built into the Python __________ can be used by simply calling the required function.

A

interpreter

90
Q

A(n) __________ chart is also known as a structured chart.

A

hierarchy

91
Q

What are the data items in a list called?

A

elements

92
Q

The primary difference between a tuple and a list is that

A

once a tuple is created, it cannot be changed

93
Q

Which list will be referenced by the variable number after the following code is executed?

number = range(0, 9, 2)

A

[0, 2, 4, 6, 8]

94
Q

Which method or operator can be used to concatenate lists?

A

+Which method can be used to convert a list to a tuple?

95
Q

Which method can be used to convert a list to a tuple?

A

tuple

96
Q

Which method can be used to convert a tuple to a list?

A

list

97
Q

T/F: Lists are dynamic data structures such that items may be added to them or removed from them.

A

True

98
Q

T/F: A list cannot be passed as an argument to a function.

A

False

99
Q

T/F: The remove method removes all occurrences of an item from a list.

A

False

100
Q

T/F: The index of the first element in a list is 1, the index of the second element is 2, and so forth.

A

False

101
Q

T/F: The index -1 identifies the last element in a list.

A

True

102
Q

T/F: To calculate the average of the numeric values in a list, the first step is to get the total of values in the list

A

True

103
Q

T/F: In order to create graphs using the matplotlib package, you need to import the pyplot module.

A

True

104
Q

T/F: The sort method rearranges the elements of a list so they are in ascending or descending order.

A

False

105
Q

T/F: In slicing, if the end index specifies a position beyond the end of the list, Python will use the length of the list instead.

A

True

106
Q

To refer to an item in a list, you code the list name followed by

A

an index number in brackets, starting with the number 0

107
Q

The __________ method adds an item to the end of a list.

A

append()

108
Q

Which of these methods would you use to insert the item “melon” after “grapes” in the following list?
fruit = [“apple”, “banana”, “grapes”, “mangos”, “oranges”]

A

fruit.insert(3, “melon”)

109
Q

Which of these methods would you use to remove the item “mangos” from the following list?
fruit = [“apple”, “banana”, “grapes”, “mangos”, “oranges”]

A

fruit.remove(“mangos”) or fruit.pop(3)

110
Q

The primary difference between a tuple and a list is that a tuple

A

is immutable

111
Q

Given the following list, what is the value of ages[5]?
ages = [22, 35, 24, 17, 28]

A

None, index error

112
Q

Given the following list, what is the value of names[2]?
names = [“Lizzy”, “Mike”, “Joel”, “Anne”, “Donald Duck”]

A

Joel

113
Q

To work with a file when you’re using Python, you must do all but one of the following. Which one is it?

A

decode the file

114
Q

Which of the following is not true about a CSV file?

  • Each row or record in the file usually ends with a new line character.
  • The columns or fields are usually separated by commas.
  • The first line is ALWAYS a header line.
  • To write data to a file, you need to get a writer object.
A

The first line is ALWAYS a header line.

115
Q

To determine the length of a string that’s in a variable named city, you can use

A

len(city)

116
Q

Which of the following symbols is used for string concatenation?

  • *
  • =
  • +
  • -
A

+

117
Q

Each item in a dictionary is

A

key-value pair

118
Q

To delete all items from a dictionary you can

A

use the clear() method

119
Q

How many items does the following dictionary contain?
flowers = {“red”: “rose”, “white”: “lily”, “yellow”: “buttercup”}

A

3

120
Q

The items() method returns a

A

object containing all of the key/value pairs in a dictionary