Test 1 Flashcards

Chapter 1, 2, 3, 4 - Checkpoint Questions

1
Q

What is a program?

A

A program is a set of instructions that a computer follows to perform a task.

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

What is hardware?

A

Hardware is all the physical devices, or components, of which a computer is made.

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

List the five major components of a computer system?

A
  • CPU (central processing unit)
  • Main Memory
  • Secondary storage devices
  • Input devices
  • Output devices
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What part of the computer actually runs programs?

A

The CPU

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

What part of the computer serves as a work area to store a program and its data while the program is running?

A

Main Memory

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

What part of the computer holds data for long periods of time, even when there is no power to the computer?

A

Secondary Storage

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

What part of the computer collects data from people and from other devices?

A

Input devices

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

What part of the computer formats and presents data for people or the devices?

A

Output devices

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

What fundamental set of programs control the internal operations of the computer’s hardware?

A

The operating system

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

What do you call a program that performs a specialized task, such as a virus scanner, a file compression program, or a data backup program?

A

A utility program

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

Word processing programs, spreadsheets programs, email programs, web browsers, and game programs belong to what category of software?

A

Application software

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

What amount of memory is enough to store a letter of the alphabet or a small number?

A

One byte

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

What do you call a tiny “switch” that can be set to either on or off?

A

A bit

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

In what numbering system are all numeric values written as sequences of 0s and 1s?

A

The binary numbering system

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

What is the purpose of ASCII?

“American Standard Code for Information Interchange”

A

It is an encoding scheme that uses a set of 128 numeric codes to represent the English letters, various punctuation marks, and other characters. These numeric codes are used to store characters in a computer’s memory.

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

What encoding scheme is extensive enough to represent the characters of many of the languages in the world?

A

Unicode

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

What do the terms “digital data”and “digital device” mean?

A

Digital data is data that is stored in binary

Digital devices is any device that works with binary data

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

A CPU understands instructions that are written only in what language?

A

Machine Language

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

A program has to be copied into what type of memory each time the CPU executes it?

A

Main Memory (RAM)

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

When a CPU executes the instructions in the program, it is engaged in what process?

A

The fetch-decode-execute cycle

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

What is assembly language?

A

It is an alternative to machine language. Instead of using binary numbers for instructions, assembly language uses short words that are known as mnemonics.

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

What type of programming language allows you to create powerful and complex programs without knowing how the CPU works?

A

A high-level language

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

Each language has a set of rules that must be strictly followed when writing a program.
What is this set of rules called?

A

Syntax

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

What do you call a program that translates a high-level language program into a separate machine language program?

A

A compiler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What do you call a program that both translates and executes the instructions in high-level language program?
An interpreter
26
What type of mistake is usually caused by a misspelled keyword, a missing punctuation character, or the incorrect use of an operator?
A syntax error
27
Who is a programmers customer?
Any person, group, or organization that is asking you to write a program
28
What is a software requirement?
A single function that the program must perform in order to satisfy the customer
29
What is an algorithm?
A set of well-defined logical steps that must be taken to perform a task
30
What is pseudocode?
An informal language that has no syntax rules and is not meant to be compiled or executed. Instead, programmers use pseudocode to create models, or “mock-ups,” of programs.
31
What is a flowchart?
A diagram that graphically depicts the steps that take place in a program
32
What do the following symbols mean in a flowchart? Oval, Parallelogram, Rectangle
Ovals - terminal symbols Parallelograms - are either output or input symbols Rectangle- are processing symbols
33
What is a variable?
A name that references a value in the computer's memory
34
Which of the following are illegal variable names in Python, and why? x 99bottles July2009 theSalesFigureForFiscalYear r&d grade_report
- 99bottles is illegal because it begins with a number - r&d is illegal because the & character is not allowed
35
What will the following code display? -val=99 -print(‘The value is’, ‘val’)
The value is val
36
Look at the following assignment statements: -value1 = 99 -value2 = 45.9 -value3 = 7.0 -value4 = 7 -value5 = ‘abc’ After these statements execute, what is the Python data type of the values referenced by each variable?
-int -float -float -int -string
37
What will be displayed by the following program? -my_value = 99 -my_value = 0 -print(my_value)
0
38
You need the user of a program to enter a customer’s last name. Write a statement that prompts the user to enter this data and assigns the input to a variable.
last_name = input("Enter customer's last name: ")
39
You need the user of a program to enter the amount of sales for the week. Write a statement the prompts the user to enter this data and assigns the input to a variable.
sales = float(input('Enter the sales for the week: '))
40
Write the value of each expression? 1. 6+3*5 2. 12/2-4 3. 9+14 * 2 -6 4. (6+2) * 3 5. 14 / (11-4) 6. 9 + 12 * (8 -3)
- 21 - 2 -31 -24 -2 -69
41
What value will be assigned? Result = 9//2
4
42
What value will be assigned? Result = 9%2
1
43
What is string concatenation?
The appending of one string to the end of another
44
What value will be assigned? Results = ‘1’ + ‘2’
12
45
What value will be assigned? Result = ‘h’ ‘e’ ‘l’ ‘l’ ‘o’
hello
46
How do you suppress the print function’s ending newline?
If you do not want the print function to start a new line of output when it finishes displaying its output, you can pass the special argument end = ' ' to the function
47
How can you change the character that is automatically displayed between multiple items that are passed to the print function?
You can pass the argument sep = to the print function, specifying the desired character
48
What is the ‘\n’ escape character?
It is the newline escape character
49
In the following statement, what is the purpose of the number 10 in the format specifier? -print(f’{name:10}’)
It is a field width designator. It indicates that the value should be displayed in a field that is a minimum of 10 spaces wide.
50
In the following statement, what is the purpose of the number 15 in the format specifier? -print(f’{number:15,d})
It is a field width designator. It indicates that the value should be displayed in a field that is a minimum of 15 spaces wide.
51
In the following statement, what is the purpose of the number 8 in the format specifier? -print(f’{number:8, .2f}’)
It is a field width designator. It indicates that the value should be displayed in a field that is a minimum of 8 spaces wide.
52
What are these alignment designators? < > ^
Left- aligns Right- aligns Center- aligns Placement Example: print(f’{number:>12d}’)
53
What are 3 advantages of using names constants?
(1) Named constants make programs more self-explanatory (2) widespread changes can easily be made to the program (3) they help to prevent the typographical errors that are common when using magic numbers.
54
Write a Python statement that defines a named constant for a 10 percent discount.
DISCOUNT_PERCENTAGE = 0.1
55
A _______ error does not prevent the program from running, but causes it to produce incorrect results
Logic
56
A ________ is a single function that the program must preform in order to satisfy the customer
software requirement
57
A _____ is a sequence of characters
String
58
A _______ is a name that references a value in the computer’s memory.
Variable
59
A ______ is an any hypothetical person using a program and providing input for it.
User
60
Short notes placed in different parts of a program explaining how those parts of the program work are called _______.
Comments
61
A _______ makes a variable reference a value in the computers memory.
assignment statement
62
In the expression 12 + 7, the values on the right and left of the + symbol are called _____.
Operands
63
What operator performs integer division?
//
64
What operator raises a number to a power?
**
65
What operator performs decision, but instead of returning the quotient it returns the remainder?
%
66
A string literal in Python must be enclosed in ____.
either single-quotes or double-quotes
67
Computer programs typically perform what 3 steps?
1. Input is received 2. Some process is performed on the input 3. Output is produced
68
What is the difference between floating-point division and integer division?
Integer division gives result as a whole number while floating-point division is given as a decimal.
69
What is a magic number? Why are magic numbers problematic?
A magic number is an unexplained value that appears in a program's code. 1. It can be difficult for someone reading the code to determine the purpose of the number 2. If the magic number is used in multiple places in the program, it can take lots of effort to change the number in each location 3. You take the risk of making a typographical mistake
70
The computer stores a program while the program is running, as well as the data that the program is working with, in_____.
main memory?
71
Negative numbers are encoded using the ____ technique
two's complement
72
Real Numbers are encoded using the ____ technique
floating point
73
The _____ translates an assembly language program to a machine language program
assembler
74
The words that make up a high-level programming language are called ______.
keywords or reserved words
75
A _____________structure can execute a set of statements only under certain circumstances.
decision
76
A(n) _____ expression has a value of either True or False.
Boolean
77
The symbols >, <, and == are all ________operators.
relational
78
A(n) _____ structure tests a condition and then takes one path if the condition is true, or another path if the condition is false.
dual alternative decision
79
and, or, and not are _________operators.
logical
80
The _________ operator takes a Boolean expression as its operand and reverses its logical value.
not
81
A _________is a Boolean variable that signals when some condition exists in the program.
flag
82
A  __________-controlled loop uses a true/false condition to control the number of times that it repeats.
condition
83
Each repetition of a loop is known as a(n) ________.
cycle
84
The while loop is a _________type of loop.
pretest
85
The -= operator is an example of a(n) _______operator.
augmented assignment
86
A(n)  ______is a special value that signals when there are no more items from a list of items to be processed. This value cannot be mistaken as an item from the list.
sentinel
87
The integrity of a program’s output is only as good as the integrity of the program’s __________.
programming language
88
The input operation that appears just before a validation loop is known as the  ________.
priming read
89
Validation loops are also known as __________ .
error trap
90
3.1 What is a control structure?
A logical design that controls the order in which a set of statements execute
91
3.2 What is a decision structure?
It is a program structure that can execute a set of statements only under certain circumstances.
92
3.5 What types of relationships between values can you test with relational operators?
You can determine whether one value is greater than, less than, greater than or equal to, less than or equal to, equal to, or not equal to another value.
93
3.6 Write an if statement that assigns 0 to x if y is equal to 20.
if y == 20:  x = 0
94
3.7 Write an if statement that assigns 0.2 to commissionRate if sales is greater than or equal to 10000.
if sales >= 10000: commissionRate = 0.2
95
3.9 What statement do you use in Python to write a dual alternative decision structure?
if-else
96
3.10 When you write an if-else statement, under what circumstances do the statements that appear after the else clause execute?
When the condition is false
97
3.14 What is a compound Boolean expression?
It is an expression that is created by using a logical operator to combine two Boolean subexpressions.
98
3.17 Explain how short-circuit evaluation works with the and and or operators.
The and operator: If the expression on the left side of the and operator is false, the expression on the right side will not be checked. The or operator: If the expression on the left side of the or operator is true, the expression on the right side will not be checked.
99
3.18 Write an if statement that displays the message “The number is valid” if the value referenced by speed is within the range 0 through 200.
if speed >= 0 and speed <= 200: print('The number is valid')
100
3.19 Write an if statement that displays the message “The number is not valid” if the value referenced by speed is outside the range 0 through 200.
if speed < 0 or speed > 200: print('The number is not valid')
101
3.20 What values can you assign to a bool variable?
True or False
102
3.21 What is a flag variable?
A variable that signals when some condition exists in the program
103
4.4 What is a loop iteration?
An execution of the statements in the body of the loop
104
4.5 Does the while loop test its condition before or after it performs an iteration?
Before
105
4.6 How many times will 'Hello World' be printed in the following program? count = 10 while count < 1: print('Hello World')
None. The condition count < 0 will be false to begin with.
106
4.8 Rewrite the following code so it calls the range function instead of using the list [0, 1, 2, 3, 4, 5]: for x in [0, 1, 2, 3, 4, 5]: print('I love to program!')
for x in range(6): print('I love to program!')
107
4.9 What will the following code display? for number in range(6): print(number)
0 1 2 3 4 5
108
4.10 What will the following code display? for number in range(2, 6): print(number)
2 3 4 5
109
4.11 What will the following code display? for number in range(0, 501, 100): print(number)
0 100 200 300 400 500
110
4.12 What will the following code display? for number in range(10, 5, −1): print(number)
10 9 8 7 6
111
4.14 Should an accumulator be initialized to any specific value? Why or why not?
Yes, it should be initialized with the value 0. This is because values are added to the accumulator by a loop. If the accumulator does not start at the value 0, it will not contain the correct total of the numbers that were added to it when the loop ends.
112
4.15 What will the following code display? total = 0 for count in range(1, 6): total = total + count print(total)
15
113
4.16 What will the following code display? number 1 = 10 number 2 = 5 number 1 = number 1 + number 2 print(number1) print(number2)
15 5
114
4.17 Rewrite the following statements using augmented assignment operators: quantity = quantity + 1 days_left = days_left − 5 price = price * 10 price = price / 2
quantity += 1 days_left −= 5 price *= 10 price /= 2