NEW
Font size
WorksheetsComputer Science Principles Unit 3 Exam
Total questions: 20
Worksheet time: 10mins
Refer to the following code segment:The procedure check is supposed to display a statement correctly comparing the size of the two provided numbers, value1 and value2. Which of the following changes to the code would be the best choice to make the procedure work as intended?
Swap the two DISPLAY blocks
Add another IF / ELSE block, nested in the ELSE section
Without changing the DISPLAY blocks, in the condition for the IF block, use the symbol ≤ instead of <.
Send 3 values to the procedure instead of two
What is the output of the following block? (Hint: think about case sensitivity.)
False
None of the options listed.
True
February
Which of the following cannot be represented by a single binary digit?
The result of a single coin flip
Which color is currently being shown by a traffic light
Whether an integer is an odd or an even number
The position (on or off) of a single light switch
The list mine is initialized with the values -- green, red, blue, purple, yellow, black -- and the list yours is initialized with the values -- green, red, black, blue. What will be displayed after the following code segment runs?
There are 2 duplicates
There are 3 duplicates
There are 0 duplicates
None of the messages listed are displayed: Partway through, an error message is produced and the program terminates.
Which of the following decimal (base-10) values is equivalent to the binary (base-2) value 101001?
22
41
37
82
Which of the following statements correctly demonstrates that the two algorithms are NOT equivalent?
Both algorithms will correctly display the number of integers greater than 5 on the list [1, 7, 2, 0]
Algorithm I will correctly display the number of integers greater than 5 on the list [4, 10, 5, 1], but Algorithm II will not.
Neither algorithm will correctly display the number of integers greater than 5 on the list [1, 5, 8, -2]
Algorithm II will correctly display the number of integers greater than 5 on the list [-6, 1, 4, 1], but Algorithm I will not.
ASCII characters can also be represented by binary numbers. According to ASCII character encoding, which of the following letters is represented by the binary (base 2) number 1010100?
N
T
P
W
Which of the following could be displayed when this segment of code is executed, assuming that the block will sort the parameter list in alphabetical order from A to Z, and the user responds to each input?
Alex Joe Matt
Steve Andrew Kevin
Tim Tim Tim
Sally Heather Barbie
This code is an example of what type of encoding?
Multi-length width
Fixed width
Variable width
Incremental width
A large company uses 10-bit binary numbers to identify its employee records. It plans to change this system to use 12-bit binary numbers instead. Which of the following statements best describes the effects of this change?
2 times the number of individual records can potentially be stored.
10 times the number of individual records can potentially be stored.
4 times the number of individual records can potentially be stored.
100 times the number of individual records can potentially be stored.
Given a list of integers, sequence, and an integer, value, which of the following best describes what the code segment does?
The sum of the items in sequence that are less than value is displayed.
The total number of items in sequence is displayed.
The number of items in sequence that are greater than value is displayed.
The number of items in sequence that are less than value is displayed.
Which of the following is not true about digitizing physical media?
Media in a digital form is easier to sell and resell.
The digital version is always equally as good as the physical one in terms of quality.
We can more easily edit the media when it is in a digital form.
When media is in a digital format, it is much easier to share with others.
Lists are widely used in programming, however, lists are not necessary for all programming tasks. In which of the following situations would you be least likely to need to use a list in a program?
Keeping a record of a character's previous moves in a game.
Editing the names of all sprites in a program by removing the first letter of each name.
Tracking the last song that played in a game, so that people playing the game don't hear the same song twice in a row.
Providing a group of snacks that a program can randomly select as a reward every time a player reaches the end of a maze.
Which of the following scenarios will likely result in an overflow error?
A program attempts to store as an integer the result of the integer division 9/2.
A program attempts to add two integers when one has not been assigned a value.
A program which stores positive integers using 3 bits attempts to multiply the (decimal) integers 2 and 3.
A program which stores positive integers using 4 bits attempts to add the (decimal) integers 7 and 9.
What list will be displayed when the following code segment is run?
banana, banana, banana, banana, apple, grape, kiwi, orange
banana, apple, banana, grape, banana, kiwi, banana, orange
banana, banana, apple, banana, grape, kiwi, orange
banana, apple, banana, grape, banana, kiwi, orange
Sam’s password is known to be formed of 3 decimal digits (0-9) in a given order. Karren and Larry are attempting to determine Sam’s password by testing all possible combinations. If they are only able to try 10 combinations every day, how many days would it take to try all the possible combinations?
1000
100
3
73
Which of the following best describes the behavior of the program?
The program always displays 0.
The program displays the number of words not equal to stopValue subtracted from the number of words equal to stopValue.
The program displays the number of items in the list as long as stopValue is in the list.
The program correctly displays the number of items in the list which do not equal stopValue.
Which of the following changes will reduce the number of operations performed by the program without making it incorrect?
Interchanging line 11 and line 12
Interchanging line 1 and line 3
Interchanging line 10 and line 11
nterchanging line 2 and line 3
The program makes use of a procedure named IsFirstOccurence. Which of the following definitions of this procedure would cause the program to function as intended?
PROCEDURE IsFirstOccurence(list,
pos)
{
index ← 1
REPEAT UNTIL (index = pos)
{
IF (list [index] = list [pos])
{
RETURN (true)
}
ELSE
{
RETURN (false)
}
index ← index + 1
}
}
PROCEDURE IsFirstOccurence(list,
pos)
{
index ← 1
REPEAT UNTIL (index = pos)
{
IF (pos = index)
{
RETURN (list[pos])
}
index ← index + 1
}
}
PROCEDURE IsFirstOccurence(list,
pos)
{
index ← 1
REPEAT UNTIL (index = pos)
{
IF (list [index] = list [pos])
{
RETURN (false)
}
index ← index + 1
}
RETURN (true)
}
PROCEDURE IsFirstOccurence(list,
pos)
{
index ← 1
REPEAT UNTIL (index > LENGTH (list))
{
IF (list [index] = list [pos])
{
RETURN (false)
}
index ← index + 1
}
RETURN (true)
}
Which of the following gives a correct, ordered set of instructions which will create a code segment swapping the initial values of a and b?
I, II, III
IV, I, II
III, IV, II
II, I, IV
