Code Segments and Logic Problems

Code Segments and Logic Problems

Assessment

Interactive Video

Computers, Education

10th - 12th Grade

Practice Problem

Medium

Created by

Emma Peterson

Used 7+ times

FREE Resource

This video tutorial by Mrs. Juliolano from Hamilton Southeastern High School reviews key questions for the AP Computer Science Principles exam. It covers topics such as converting numeric scores to letter grades, understanding parameter X, detecting duplicates in lists, grading logic for homework, adjusting scores with penalties, tracing variable assignments, updating word variables, string manipulation, and determining discount eligibility. The session concludes with a review of the topics covered.

Read more

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is provided to students during the AP Computer Science Principles exam to help them understand the code?

A programming language guide

An exam reference sheet

A calculator

A textbook

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following code segments correctly assigns a letter grade based on a numeric score?

if score > 90 then grade = 'A' else grade = 'B'

if score > 90 then grade = 'A' else if score >= 80 then grade = 'B' else grade = 'C'

if score >= 80 then grade = 'B' else if score > 90 then grade = 'A' else grade = 'C'

if score < 80 then grade = 'C' else if score <= 90 then grade = 'B' else grade = 'A'

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be displayed if the parameter x is negative in the given procedure?

Nothing

False

Error

True

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How does the code segment determine if a list contains duplicate values?

By comparing each element to the element that immediately follows

By comparing each element to the element that immediately precedes

By comparing each element to all subsequent elements in the list

By comparing each element to all other elements in the list

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

For which values of num correct does the code segment not display the intended grade?

8 and 6

7 and 6

9 and 7

9 and 8

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What change should be made to the code segment to ensure it reduces the score by penalty correctly?

Change line 1 to if score < 0

Change line 1 to if score + penalty > 0

Interchange lines 3 and 7

Change line 1 to if score + penalty < 0

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the final value of r after executing the given code segment?

20

30

40

10

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?