wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Unit 2 Review

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What would be the final value of the variable third once the following program is complete?

first ← 2

second ← 3

third ← first * second

second ← third - first

first ← first + second + third

third ← second * first

a)

33

b)

6

c)

36

d)

48

2.

Consider the block of code below:


What would be the most appropriate substitute for the missing Boolean Operator if the intention is to display “True” for only values of x between, but not equal to values of 0 and 10?

a)

NOT

b)

AND

c)

OR

d)

XOR

3.

Which of the following CollegeBoard AP Computer Science Principles Pseudocode commands is used to record something typed by a user of the program so that it can be used in the program?

a)

Input()

b)

a MOD b

c)

DISPLAY (expression)

d)

RANDOM (a, b)

4.

Given the following code segment, what would be displayed if age were initialized with a value of 18?

a)

Nothing will be displayed

b)

Group 1

c)

Group 2

d)

Group 1 and Group 2

5.

Moore's Law describes the rate at which the number of transistors on a single chip doubles over time. Which of the following assumptions CANNOT be inferred as a direct consequence of this rate of doubling?

a)

Five years from now, computer programs will be able to solve complex problems faster than today's computer programs.

b)

Five years from now, top-of-the-line computers will have faster processors (CPUs) than today's top-of-the-line computers.

c)

Five years from now, electronic components can be made smaller than today's equivalent electronic components.

d)

Five years from now, web pages will require less memory (RAM) than today's web pages.

6.

Consider the following code segment that allows a customer to request their preferred beverage and size of beverage (ounces).


What is displayed if the user enters “16” and then “coffee” when the program runs?

a)

Bottle of Soda

b)

Can of Soda

c)

Grande Coffee

d)

Short Coffee

7.

A particular problem is currently not able to be practically solved by using an algorithm. Which of the following statements about the problem could possibly be true?

I.No algorithm has yet been developed which would solve this problem, but it is possible one may be developed in the future.

II. An algorithm has been developed which would solve this problem but technology is not yet available which would compute this algorithm fast enough to be practicable.

III. It is impossible to develop an algorithm which would solve this problem.

a)

I

b)

I and II

c)

I and III

d)

I, II, III

8.

The following question uses a robot and a grid of squares. The robot is represented as a triangle, which is initially in the bottom left square of the grid and facing right.


Consider the following code segment, which moves the robot on the grid:


Which of the following shows the location of the robot after running the code segment?

a)
b)
c)
d)
9.

Frankie is considering whether to use a binary or linear search in her program to find a value in a sorted list. When she tests the algorithms on selection of short lists of fixed-length lists she finds that the binary search is faster on average than the linear search. Another programmer suggests she tests both algorithms on a selection of lists which are 10 times as long as her original test lists. Which of the following best describes the likely results of this test?

a)

The linear search will now be faster on average than the binary search.

b)

The binary search will still be faster on average than the linear search, and the difference in run times between the two searches will be approximately the same as for the shorter lists.

c)

The binary search will still be faster on average than the linear search, and the difference in run times between the two searches will be significantly more than 10 times greater than for the shorter lists.

d)

The binary search will still be faster on average than the linear search, and the difference in run times between the two searches will be approximately 10 times greater than for the shorter lists.

10.

Sally notices that she has the same set of 10 blocks in her code in multiple places. She decides to create a new block (procedure) in Scratch so that she can simply replace those 10 blocks with one procedure. Which of the following gives the best ways in which this could be beneficial to Sally when she debugs and reasons through her program?

Select two answers.

a)

The procedure can make the code section more abstract, so she doesn’t have to think through all 10 blocks each time she comes across them in her code.

b)

If there is an error in the procedure, she can fix the error in the procedure without having to search through her code for each place the procedure is used.

c)

The procedure will make the program more efficient, spending less time running the same set of 10 blocks over and over again.

d)

She will be able to hide the function of this code block easier meaning others cannot copy her work.

11.

What would be the final value of the variable var3 once the following program has run?

var1 ← 4

var2 ← 2

var3 ← var1 + var2

var1 ← var3 * var2

var2 ← var2 + var1 – var3

var3 ← var1 + var2

a)

6

b)

20

c)

8

d)

12

12.

According to Moore’s Law, increases in technological performance should approximately double every year. If this holds true, by what factor can performance be expected to increase over 5 years?

a)

10 times

b)

100 times

c)

32 times

d)

16 times

13.

What is displayed as a result of running the program if the initial value of a is 6, and the initial value of b is 11?

IF (a = b) { DISPLAY (“January”) }

ELSE { IF (a > b) { DISPLAY (“February”) }

ELSE { IF (a > 0) { DISPLAY (“March”) }

ELSE { DISPLAY (“April”) } } }

a)

January

b)

February

c)

March

d)

April

14.

“Every problem may be theoretically solved using an algorithm, however for some problems this is not practical because it would take an unreasonably long time.”

Which of the following statements best describes the truth of the above statement?

a)

All parts of the statement are completely false.

b)

The statement is false: today’s technology allows any algorithm to be run in a reasonable time.

c)

All parts of the statement are completely true

d)

The statement is false: there are some problems for which no algorithm can be developed to solve them.

15.

Which of the following statements could replace condition to make the following code fragment an infinite loop?


Y=2

repeat until (condition)

y = y - 5

a)

y ≥ 8

b)

y = -108

c)

y < -53

d)

y ≠ -3