wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Code.org APCSP Unit 7 Assessment

Total questions: 8

Worksheet time: 5mins

Name
Class
Date
1.

Which code segment will guarantee that the robot makes it to the grey square without hitting a wall or a barrier (black square)?


Here is the API for a robot library.

// moves the robot forward

function moveForward();


// turns the robot to the left

function rotateLeft();


// turns the robot to the right

function rotateRight();


// checks if a robot can move in any direction

// direction {string} - the direction to be checked

// return {Boolean} - true if the robot can move in that direction, otherwise returns false

function canMove(direction);

a)
b)
c)
d)
2.

You have imported a library with the birthMonth() function. Based on the API, how many strings are inputed to calculate the birth month?

a)

1

b)

4

c)

0

d)

3

3.

Which term refers to a solution to a large problem that is based on the solutions of smaller subproblems.

a)

procedural abstraction

b)

API

c)

modularity

d)

library

4.

This function finds the minimum number in a list. What should <MISSING CODE SEGMENT> be replaced with in order for this function to operate as expected?

a)

numList[i] = min;

b)

min = numList[i];

c)

min = numList;

d)

numList = min;

5.

What is one of the benefits of using a library in a program?

a)

simplifies creating a complex program

b)

increases development time

c)

removes all testing

d)

reduces abstractions in the program

6.

Barry is making a program to process user birthdays.

The program uses the following procedure for string slicing:


NameDescriptionSUBSTRING (string, startPos, numChars)Returns a substring of string starting at startPos of length numChars. The first character in the string is at position 1.


His program starts with this line of code:

userBday ← "03/31/84"


Which of these lines of code displays the day of the month ("31")?


Choose 1 answer:

a)

display (substring (userBday, 3, 1)

b)

display (substring (userBday, 3, 3)

c)

display (substring (userBday, 4, 1)

d)

display (substring (userBday, 4, 2)

7.

Marlon is programming a simulation of a vegetable garden. Here's the start of his code:

temperature ← 65

moisture ← 30

acidity ← 3

DISPLAY (acidity)

DISPLAY (temperature)

DISPLAY (moisture)

a)

65 30 3

b)

3 30 65

c)

3 65 30

8.

Landry is writing a program to help her calculate how long it will take to read the books she received for Christmas.

The procedure calcReadingHours returns the number of hours it will take her to read a given number of pages, if each page takes a given number of minutes to read.

PROCEDURE calcReadingHours(numPages, minPerPage)

{

totalMin ← numPages * minPerPage

RETURN totalMin / 60

}

Landry then runs this line of code:

hoursNeeded ← calcReadingHours(180, 2)

What value is stored in hoursNeeded?

(a)