wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

AP CSP Unit 1

Total questions: 40

Worksheet time: 30mins

Name
Class
Date
1.

Which of the following best describe examples of abstraction?

Select two answers.

a)

A series of steps for creating a model airplane is laid out in a clear order, with specific instructions in great detail for completing each step.

b)

Several developers are working on a program together. In order to complete the work efficiently, they split the program up into several parts, and each work on a section, testing as they proceed. When code is complete they add it to a master program.

c)

A sheet of music for guitar is written as a series of chords (e.g C, Am, G7). Each of these represents multiple notes which are played simultaneously on different strings of a guitar.

d)

A developer writing a program for calculating properties of shapes uses a variable pi to store a decimal approximation of the number π (~3.14159). They use this variable whenever they need to use the number π to calculate an area or volume.

2.

Rick is in charge of a team developing a program which will be used by businesses to control stock. The team has already consulted with potential clients and developed an idea of what inputs will be required and the likely outputs that will be produced from these inputs. Which of the following should Rick and his team do next?

a)

Write segments of code in different languages to see which language will be most suitable for the job.

b)

Plan the structure of the program and determine how the major algorithms will work.

c)

Make a list of bugs which will occur during development and propose ways these could be fixed.

d)

Decide on the schedule for updates and maintenance of the code.

3.

Which of the following is a simplified but equivalent Boolean expression to the following:

(X > 0 AND X ≤ 20) OR (X > -5 AND X < 15)`

a)

(X < -5) AND (X ≥ 20)

b)

(X > 0) AND (X < 15)

c)

(X < 0) AND (X > 15)

d)

(X > -5) AND (X ≤ 20)

4.

Consider constructing an algorithm for a robot that can only perform the following three predefined operations.

MOVE_FORWARD ( ): The robot moves one square forward in the direction it is facing.

ROTATE_LEFT ( ): The robot rotates in place 90 degrees counterclockwise (i.e., makes an in-place left turn).

ROTATE_RIGHT ( ): The robot rotates in place 90 degrees clockwise (i.e., makes an in-place right turn).

Which of the following algorithms could successfully cause the robot to trace out a “T”-shaped path as drawn above?

a)

Step 1: MOVE_FORWARD ( )

Step 2: ROTATE_LEFT ( )

Step 3: ROTATE_LEFT ( )

Step 4: MOVE_FORWARD ( )

Step 5: ROTATE_RIGHT ( )

Step 6: MOVE_FORWARD ( )

b)

Step 1: MOVE_FORWARD ( )

Step 2: MOVE_FORWARD ( )

Step 3: ROTATE_LEFT ( )

Step 4: MOVE_FORWARD ( )

Step 5: MOVE_FORWARD ( )

Step 6: ROTATE_RIGHT ( )

Step 7: ROTATE_RIGHT ( )

Step 8: MOVE_FORWARD ( )

c)

Step 1: MOVE_FORWARD ( )

Step 2: MOVE_FORWARD ( )

Step 3: ROTATE_RIGHT ( )

Step 4: MOVE_FORWARD ( )

Step 5: ROTATE_RIGHT ( )

Step 6: ROTATE_RIGHT ( )

Step 7: MOVE_FORWARD ( )

d)

Step 1: MOVE_FORWARD ( )

Step 2: MOVE_FORWARD ( )

Step 3: ROTATE_LEFT ( )

Step 4: ROTATE_LEFT ( )

Step 5: MOVE_FORWARD ( )

Step 6: ROTATE_RIGHT ( )

Step 7: MOVE_FORWARD ( )

Step 8: MOVE_FORWARD ( )

5.

Jama is creating a program which calculates the square roots of whole numbers. The program will store the results of each square-root as a variable. Which of the following data-types would be best used for this variable?

a)

int

b)

bool

c)

string

d)

float

6.

Roxanne is writing a program which will be used to display information to passengers on a flight. Some of the variables she will use for her program are as follows.

speed - the current speed of the airplane relative to the ground in meters per second

passengers - the number of passengers on-board the plane

destination - the name of the destination airport of the flight

Which of the following correctly describes the types which would be best used for each of these variables?

a)

speed - string, passengers - int, destination - float

b)

speed - float, passengers - string, destination - int

c)

speed - float, passengers - int, destination - string

d)

speed - int, passengers - float, destination - string

7.

Which of the following describes algorithmic solutions to problems:

I. A set of step by step instructions for assembling a piece of furniture.

II. A flowchart used to make important decisions on which actions to take in an emergency situation

III. A recipe for baking a cake with detailed numbered steps to follow

a)

I, II, and III

b)

I and III only

c)

II and III only

d)

I and II only

8.

Which of the following is an example of code written in a high-level programming language?

a)

Add the number 2 to the number 5, then subtract this from the number 10 and display the answer.

b)

LD R0 8

LD R1 3

SUB R1 R0

LD R2 1

ADD R2 R0

ST R0 X

c)

num1 = 8 - 3

num2 = 2 * num1 + 1

print(num2)

d)

00101100

01010000

11011000

10110111

9.

Which of the following statements comparing low-level programming languages (such as assembly language) and high-level programming languages (such as python or java) are correct?

Select two answers.

a)

A program written in a low-level language is closer in syntax to the binary code understood by computers than a program written in a high-level language.

b)

A program written in a high-level language will usually be easier for a person reading the code to understand than one written in a low-level programming language.

c)

A low-level programming language is easier to learn, but some algorithms can only be written using high level programming languages.

d)

A low-level program can be easily understood and assembled on any hardware, while the use of a compiler means a high-level program is difficult to use on different systems.

10.

Which of the following statements about variables in programming are true?

I. Variables allow a value to be stored for future use

II. Once the value of a variable is set it cannot be changed

III. The name given to a variable is important for human comprehension, but not for the computer.

a)

I, II, and III

b)

II only

c)

I and III only

d)

I only

11.

Erin has written a program which presents a user with multiple-choice quiz questions to answer and calculates a percent score based on the number the user got right or wrong. Each question has 5 possible answers, and scores presented are from 0 to 100 percent inclusive. Which of the following could be represented by a boolean variable?

a)

The number of questions in the quiz.

b)

Whether a user got a specific question right or not.

c)

The percent score of the user.

d)

The correct answer choice for a particular question.

12.

Which of the following statements are NOT true about high level programming languages? Select two answers:

a)

Code written using high level languages is relatively easy for humans to read, write and parse.

b)

Code written using high level languages is guaranteed to be ambiguous.

c)

Code written using high level languages usually requires compiling before it can be run.

d)

Any particular algorithm will be written in the same way regardless of which high level programming language is used.

13.

Rhys is creating a program which stores customer records. One variable used in the program stores the first initial of a customer’s name. Which of the following data-types could be used to store this data? Select two answers.

a)

String

b)

Boolean

c)

Character

d)

Integer

14.

The following algorithm is presented for assembling a piece of furniture from 12 individually numbered parts.

Parts 1, 5, and 11

Parts 2 and 10

Part 12

Parts 6 to 9 inclusive

Parts 3 and 4

Which of the following correctly describe issues with the way these instructions are presented?

I. There instructions lack the required descriptive qualifiers

II. The instructions lack the required imperative statements

III. The order in which the instructions should be performed is unclear

a)

I only

b)

II only

c)

I and II

d)

I, II, and III

15.

Which of the following variable types is characterized by allowing only two possible values to be stored?

a)

Array

b)

Boolean

c)

Float

d)

String

16.

Marta is writing a program for a home-automation system. Three of the variables in her program are as follows:

light - A variable which determines whether the lights in a room are switched on or off

temp - A variable which records the temperature of the room to the nearest whole degree Fahrenheit

name - A variable which records the name the user has set for the room (e.g. “kitchen”)

Which of the following correctly describes the types which would be best used for each of these variables?

a)

light - string, temp - integer, name - boolean

b)

light - boolean, temp - string, name - integer

c)

light - integer, temp - boolean, name - string

d)

light - boolean, temp - integer, name - string

17.

Which of the following best describes how abstraction makes code written in higher-level programming languages easier for humans to parse?

a)

Abstractions used in higher-level languages make them almost identical to a natural language which would be spoken by humans.

b)

Abstractions used in higher-level languages mean what a command does is easier to understand without needing to parse all the individual operations performed by the CPU.

c)

Abstractions used in higher-level languages make the code closer to the actual individual operations performed by the CPU.

d)

Abstractions used in higher-level languages remove any potential ambiguity from the code.

18.

Microsoft Excel® is a spreadsheet program that can be used for computing the average of a list of values in cells A1 through A20 with a command such as =AVERAGE(A1:A20). After the user initiates this command, the command disappears and the average (or mean) of the list of numbers appears. Why is this an abstraction?

a)

There are steps that are followed in order to complete the calculations.

b)

The average can be viewed without knowing the process of how the average was computed.

c)

There is math being used in order to calculate the average.

d)

There is an equal sign present in the command.

19.

The following algorithm is proposed for the task of baking a cake, and is presented along with a list of ingredients.

Add some ingredients from the list to a bowl

Stir

Add other ingredients to a bowl

Stir

Put in a tin in the oven

Take out tin from oven

Which of the following correctly describes an issue with the way the instructions in this algorithm is presented?

a)

The instructions lack imperative statements.

b)

The instructions do not contain any selection or iteration statements.

c)

The sequencing of the instructions is unclear.

d)

The instructions lack descriptive qualifiers.

20.

Which of the following best describes why the development process by which computer programs are created is described as “iterative”?

a)

The steps in the process must be strictly followed one after another.

b)

The process is a cycle, with results from one run of the cycle feeding into the next.

c)

The process begins with planning and design phases before any of the implementation begins.

d)

Evaluation and testing may take place throughout the process and not just at the end.

21.

Which of the following is an important step to take before beginning to write the code for a program?

a)

Write on paper or a whiteboard all the code you intend to type.

b)

Randomly generate the variable names to be used in the program.

c)

Plan the logic and anticipated input/output of the code.

d)

Plan an update and maintenance schedule for the program.

22.

Which of the following could be considered part of the beginning “state” of a Scratch program?

a)

The background image.

b)

All of the options listed.

c)

Visibility of sprites.

d)

The value of a variable.

23.

As part of the lifecycle of a program, after a computer programmer writes the code, it is then compiled and usually used to create an executable file to be run on the CPU. The code that is run through the compiler is known as what?

a)

RAM

b)

Binary Code

c)

Machine Code

d)

Source Code

24.

Subana is writing a program which will calculate the mean average of a set of numbers by adding the numbers and dividing the result by the amount of numbers. She will use a variable, avg, to store this average. Which variable type would be most suitable for avg?

a)

String

b)

Floating Point (Float)

c)

Boolean

d)

Integer (Int)

25.

Tom created the following code segments in Scratch, which are intended to create a short piece of music between them.

When the green flag is clicked, each of the three scripts is intended to run in turn, however, due to a mistake in the code, this does not happen. Which of the following changes could Tom make to ensure that all four of the scripts run as intended?

a)

Replace the block "broadcast sound 3" with the block "broadcast sound 2."

b)

None of the options listed.

c)

Both of the options listed.

d)

Delete the block "set volume to 100%."

26.

Many tasks, large and small, can be solved by performing a specific set of actions and making a particular set of decisions in very precise ways. These sets of actions and decisions are known as what?

a)

Processes

b)

Abstraction

c)

Building Blocks

d)

Algorithms

27.

Which of the following could be represented by a boolean variable?

a)

The weight of a truck as recorded at a weigh-station.

b)

The number of tech support requests made in a day.

c)

The direction a car proceeds in at a 4-way intersection.

d)

Whether a guest at a wedding is allergic to peanuts.

28.

Peter wrote the following code in scratch to make a sprite perform a series of coordinated moves, forming a “dance routine.”

The code will be used for a competition, and Peter does not want to reveal the moves performed by the sprite in his program. Currently the path taken by the sprite is traced on the screen. Which of the following changes to the code will change this and allow Peter to keep the path taken by his sprite hidden?

a)

Removing the "pen down" block.

b)

Removing the "change color effect by 25" block

c)

Removing the "think O-la-la for 2 seconds" block

d)

Removing the "set x to 0" block

29.

Which of the following types of languages is optimized for machine processing and may be written and expressed as a series of binary digits (e.g., ones and zeros), making it difficult for humans to read and write?

a)

Pseudocode

b)

Natural Language

c)

High-Level Programming Language

d)

Low-Level Programming Language

30.

Consider constructing an algorithm for a robot that can only perform the following three predefined operations.

MOVE_FORWARD ( ):The robot moves one square forward in the direction it is facing

ROTATE_LEFT ( ):The robot rotates in place 90 degrees counterclockwise (i.e., makes an in-place left turn)

ROTATE_RIGHT ( ):The robot rotates in place 90 degrees clockwise (i.e., makes an in-place right turn)

Which of the following algorithms will successfully cause the robot to trace out a square-shaped path, with the robot ending up in its original position and facing in its original direction?

a)

Step 1: MOVE_FORWARD ( )

Step 2: ROTATE_LEFT ( )

Step 3: MOVE_FORWARD ( )

Step 4: ROTATE_LEFT ( )

Step 5: MOVE_FORWARD ( )

Step 6: ROTATE_LEFT ( )

Step 7: MOVE_FORWARD ( )

Step 8: ROTATE_LEFT ( )

b)

Step 1: MOVE_FORWARD ( )

Step 2: TURN_LEFT ( )

Step 3: Repeat steps 1 and 2 four more times

c)

Step 1: MOVE_FORWARD ( )

Step 2: ROTATE_RIGHT ( )

Step 3: MOVE_FORWARD ( )

Step 4: ROTATE_RIGHT ( )

Step 5: MOVE_FORWARD ( )

Step 6: ROTATE_RIGHT ( )

Step 7: MOVE_FORWARD ( )

d)

Step 1: MOVE_FORWARD ( )

Step 2: MOVE_LEFT ( )

Step 3: MOVE_BACKWARD ( )

Step 4: MOVE_RIGHT ( )

31.

The code segments for making a Scratch program which simulates a conversation between the user and a sprite on-screen are given below.

5-2-Which of the following orders is most suitable if the program is to run without errors and produce the most realistic appearing conversation?

a)

5-2-1-3-4

b)

5-1-4-3-2

c)

5-3-1-4-2

d)

3-1-4-2-5

32.

Which of the following statements about high-level programming languages when compared to low-level programming languages is true?

a)

High-level programming languages provide programmers with less abstractions but are easier for people to read.

b)

High-level programming languages provide programmers with less abstractions and are more difficult for people to read.

c)

High-level programming languages provide programmers with more abstractions but are more difficult for people to read.

d)

High-level programming languages provide programmers with more abstractions and are easier for people to read.

33.

Joanna wishes to create a variable in her Scratch game which records the number of seconds until the game ends. Which of the following would be the most appropriate name for this variable?

a)

Variable1

b)

t

c)

amountOfTimeRemainingInTheGame

d)

time_left

34.

A group of high school students is participating in a mobile application development contest. They have a limited time frame and would like to add many features. Which of the following strategies will allow them to create the best app they can in the time allotted?

Strategy I:The students outline all goals. They make a program with all procedure names. They use software to simultaneously work on different parts of the code, frequently compiling and testing all code together. As each individual student completes one procedure, that student moves onto the next procedure.

Strategy II:The students outline all goals. They work together on some shared code, and students work with their own copies of the code on specific parts. They check in regularly and completed, correct code is added to a master program.

a)

Strategy I only.

b)

Neither Strategy I nor Strategy II will allow the students to create a quality application.

c)

Strategy I and Strategy II will both allow the students to create a quality application.

d)

Strategy II only.

35.

An entrepreneur has hired a programmer to design software to take user input and convert it to appear a certain way. The programmer is not clear on the assignment, so he asks the entrepreneur to elaborate. Which of the following would be most helpful for the programmer to ask the entrepreneur to do to make the assignment clearer?

a)

Give some examples of user input and what the result should look like.

b)

Select the most appropriate language for the application.

c)

Write some sample code to show the programmer exactly what he wants.

d)

Sit side-by side throughout the debugging process.

36.

For her 4th of July weather report, a local meteorologist wishes to predict the likelihood of the scheduled fireworks show being rained out by analyzing the most recent weather trends in the local vicinity. Which of the following sources of data would be the most appropriate for helping her make the prediction?

a)

A list of floating-point values representing the daily rainfall totals for the previous 10 days (June 24th through July 3rd).

b)

A list of integers representing the previous years in which it has rained in the area on the 4th of July.

c)

A floating-point value representing the daily rainfall total for July 4th of the previous year.

d)

A floating-point value representing the highest daily rainfall total over the last 365 days.

37.

Imagine you are programming a simple calculator using Scratch and you want to create a feature which adds a fixed number to an existing variable named “balance”. Which of the blocks below will be the most appropriate to use for this feature?

a)
b)
c)
d)
38.

Which of the following is an advantage that block-based programming languages (e.g. Scratch) have over text-based programming languages (e.g. Processing)?

a)

Block-based programming languages offer programmers more detailed control over lower-level functionality when writing a program.

b)

Block-based programming languages do not require the programmer to worry about syntax, capitalization, or punctuation.

c)

Block-based programming languages allow programmers to write programs in English and other natural languages.

d)

Programs written in block-based programming languages do not require debugging.

39.

Which of the following best represent examples of abstraction? Select two answers.

a)

A courier has to follow a detailed set of precise and detailed instructions to get to her destination. The directions given are followed one at a time in the order they appear.

b)

A single command in a high-level programming language actually requires the CPU to perform multiple different operations, each of which would be represented by a different command in machine code.

c)

Source code is copied from one program to another so that code to perform a particular operation does not need to be rewritten.

d)

A set of crochet instructions describes in full how to complete a certain type of named stitch at the start. Throughout the rest of the instructions, the stitch is referred to by its name without the full instructions being repeated.

40.

Cardel is using Java to write a SaaS program for an educational technology company. He chooses to keep his code private and to protect his work from imitation but may wish to modify or update the code in the future. Which of the following will be most likely to make it easier for him to edit his code in the future? Select two answers.

a)

Testing of the code with various inputs.

b)

Naming conventions.

c)

Adequate and appropriate comments.

d)

Syntax of the language.