Search Header Logo

CSP CodeHS U8 8.2 & 8.2

Authored by Thomas Martinez

Computers

8th - 10th Grade

CSP CodeHS U8 8.2 & 8.2
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

23 questions

Show all answers

1.

FILL IN THE BLANK QUESTION

2 mins • 5 pts

Media Image

The following code snippet processes a list of strings with a loop and conditionals:

The code relies on one string procedure, LEN(string), which returns the number of characters in the string.

2.

MULTIPLE CHOICE QUESTION

2 mins • 5 pts

Media Image

A movie website lets users create lists of their favorite movies.

When the user first starts, the website runs this code to create an empty list:

favMovies ← []

The user can then insert and remove items from the list.

Here's the code that was executed from one user's session:

"The Lion King", "The Matrix", "Lord of the Rings", "Shrek", "Spider-Man"

"The Lion King", "The Matrix", "Shrek", "Lord of the Rings", "Spider-Man"

"The Lion King", "Toy Story", "Lord of the Rings", "The Matrix", "Shrek", "Spider-Man"

"The Lion King", "Toy Story", "Shrek", "Lord of the Rings", "Spider-Man"

"The Lion King", "Toy Story", "The Matrix", "Lord of the Rings", "Shrek", "Spider-Man"

3.

MULTIPLE CHOICE QUESTION

2 mins • 5 pts

Media Image

The following numbers are displayed by a program:

4 8 12 16

The program code is shown below, but it is missing three values: <COUNTER>, <AMOUNT>, and <STEP>.

Given the displayed output, what must the missing values be?

<COUNTER> = 2, <AMOUNT> = 4, <STEP> = 2

<COUNTER> = 1, <AMOUNT> = 4, <STEP> = 2

<COUNTER> = 4, <AMOUNT> = 4, <STEP> = 1

<COUNTER> = 4, <AMOUNT> = 2, <STEP> = 1

<COUNTER> = 2, <AMOUNT> = 2, <STEP> = 1

4.

MULTIPLE CHOICE QUESTION

2 mins • 5 pts

Media Image

A program races four avatars against each other: Piceratops, Leafers, Duskpin, and Aqualine.

Here they are lined up at the start line, in that order:

After the first 3 repetitions of each loop, which avatar will be ahead?

Media Image
Media Image
Media Image
Media Image

Two avatars will be tied for the lead.

5.

MULTIPLE CHOICE QUESTION

2 mins • 5 pts

Media Image

A javelin thrower is writing code to track the distance of their throws and how far they are from their target distance.

This is what they have so far:

A friend points out that they can reduce the complexity of their code by using the abstractions of lists and loops.

The programmer decides to "refactor" the code, to rewrite it so that it produces the same output but is structured better.

Which of these is the best refactor of the code?

Media Image
Media Image
Media Image
Media Image
Media Image

6.

MULTIPLE CHOICE QUESTION

2 mins • 5 pts

Media Image

The two programs below are both intended to display the total number of overtime hours worked, based on a list of logged hours for each day of a week.

Which of these statements best describes these two programs?

Program 1 and Program 2 display the same output and involve the same number of computations.

Program 1 and Program 2 display the same output, but Program 2 requires more computations.

Program 1 and Program 2 display the same output, but Program 1 requires more computations.

Program 1 displays the expected output, while Program 2 displays more output than necessary.

Program 2 displays the expected output, while Program 1 displays more output than necessary.

7.

MULTIPLE CHOICE QUESTION

2 mins • 5 pts

Media Image

A vending machine manufacturer is writing code to determine the optimal prices for their products.

The program below processes a list of costs (in dollars and cents). The goal of the program is to create a new list that contains only the costs that can be paid entirely in quarters.

A line of code is missing, however.

What can replace <MISSING CODE> so that this program will work as expected?

APPEND(quarterCosts, costs)

INSERT(quarterCosts, costs)

APPEND(costs, cost)

INSERT(quarterCosts, cost)

APPEND(quarterCosts, cost)

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?