AP Computer Science A Unit 4 Section 2 (For Loops)

AP Computer Science A Unit 4 Section 2 (For Loops)

10th - 12th Grade

5 Qs

quiz-placeholder

Similar activities

Variables Computer Science

Variables Computer Science

10th Grade

10 Qs

W8-11

W8-11

10th - 11th Grade

10 Qs

Python Basic files

Python Basic files

10th - 12th Grade

10 Qs

Nested For Loops

Nested For Loops

10th - 12th Grade

6 Qs

CS Principles

CS Principles

9th - 12th Grade

9 Qs

AP CSP Pseudo Code

AP CSP Pseudo Code

10th - 12th Grade

8 Qs

APCSP Pseudocode

APCSP Pseudocode

10th - 12th Grade

8 Qs

Pseudocode WHILE Loops

Pseudocode WHILE Loops

10th - 12th Grade

10 Qs

AP Computer Science A Unit 4 Section 2 (For Loops)

AP Computer Science A Unit 4 Section 2 (For Loops)

Assessment

Quiz

Computers

10th - 12th Grade

Hard

Created by

Herman Galioulline

Used 138+ times

FREE Resource

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

Which of the following best explains how the difference in the two loop headers affects the output?

The output of the code segments is the same because the loops in each code segment terminate when i is 10.

The output of the code segments is the same because the loops in both code segments iterate 10 times.

The output of the code segments is different because code segment I iterates from i = 0 to i = 9 and code segment II iterates from i = 1 to i = 10.

The output of the code segments is different because code segment I iterates from i = 0 to i = 10 and code segment II iterates from i = 1 to i = 11.

Neither code segment produces output because both loop conditions are initially false.

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

Which of the following best explains how changing i < n to i <= n in line 2 will change the result?

An additional value will be printed because the for loop will iterate one additional time.

One fewer value will be printed because the for loop will iterate one fewer time.

There will be no change to the program output because the loop will iterate the same number of times.

An infinite loop will occur because the loop condition will never be false.

The body of the loop will not execute at all because the loop condition will initially be false.

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

How many $’s are printed as a result of executing the code segment?

0

5

6

7

50

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

How many times will the string "X" be printed as a result of executing the code segment?

1

7

8

35

More than 35 times, because the code segment will cause an infinite loop.

5.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Media Image

Which of the following for loops could be used to replace the for loop in the original code segment so that the original and the revised code segments store the same value in total?

Media Image
Media Image
Media Image
Media Image
Media Image