Consider the following code segment to the left.
Which of the variables have the value 50 after executing the code segment?
AP CSP Review
Quiz
•
Computers
•
9th - 12th Grade
•
Medium
Arnel Dimla
Used 68+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Consider the following code segment to the left.
Which of the variables have the value 50 after executing the code segment?
x only
y only
x and z only
x, y, and z
2.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Consider the following code segment to the left.
What is the value of r as a result of executing the code segment?
10
20
30
40
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The variable age is to be used to represent a person’s age, in years. Which of the following is the most appropriate data type for age ?
Boolean
integer
float
string
list
4.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
A student is creating an algorithm to display the distance between the numbers num1 and num2 on a number line. The following table shows the distance for several different values.
Which of the following algorithms displays the correct distance for all possible values of num1 and num2 ?
Step 1:
Add num1 and num2 and store the result in the variable sum.
Step 2: Take the absolute value of sum and display the result.
Step 1:
Subtract num1 from num2 and store the result in the variable diff.
Step 2:
Take the absolute value of diff and display the result.
Step 1:
Take the absolute value of num1 and store it in the variable absNum1.
Step 2:
Take the absolute value of num2 and store it in the variable absNum2.
Step 3:
Add absNum1 and absNum2 and display the result.
Step 1:
Take the absolute value of num1 and store it in the variable absNum1.
Step 2:
Take the absolute value of num2 and store it in the variable absNum2.
Step 3:
Subtract absNum1 from absNum2 and display the result.
5.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Three words are stored in the variables word1, word2, and word3. The values of the variables are to be updated as shown in the following table.
Which of the following code segments can be used to update the values of the variables as shown in the table?
temp ← word1
word3 ← word1
word1 ← temp
temp ← word1
word1 ← word3
word3 ← temp
temp ← word1
word1 ← word2
word2 ← word3
word3 ← temp
temp ← word3
word3 ← word2
word2 ← word1
word1 ← temp
6.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Consider the following procedures for string manipulation.
The variable initials is to be assigned a string consisting of the first letter of the string firstName followed by the first letter of the string lastName. Which of the following assigns the correct string to initials ?
initials ← concat(prefix(firstName, 1), prefix(lastName, 1))
initials ← concat(prefix(firstName, 2), prefix(lastName, 2))
initials ← prefix(concat(firstName, lastName), 1)
initials ← prefix(concat(firstName, lastName), 2)
7.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
To qualify for a particular scholarship, a student must have an overall grade point average of 3.0 or above and must have a science grade point average of over 3.2. Let overallGPA represent a student’s overall grade point average and let scienceGPA represent the student’s science grade point average. Which of the following expressions evaluates to true if the student is eligible for the scholarship and evaluates to false otherwise?
(overallGPA > 3.0) AND (scienceGPA > 3.2)
(overallGPA > 3.0) AND (scienceGPA ≥ 3.2)
(overallGPA ≥ 3.0) AND (scienceGPA > 3.2)
(overallGPA ≥ 3.0) AND (scienceGPA ≥ 3.2)
11 questions
Control Structures - Selection in Python
Quiz
•
8th Grade - University
11 questions
Casting in Java
Quiz
•
9th - 12th Grade
10 questions
IGCSE Computer Science - Chapter 9: Problem-Solving and Design
Quiz
•
9th - 10th Grade
11 questions
J277 Programming - Data Types
Quiz
•
9th - 11th Grade
6 questions
Code.org CSP Unit 4 Review
Quiz
•
9th - 12th Grade
10 questions
KS4 Programming Techniques (1)
Quiz
•
8th - 10th Grade
10 questions
C# Programming Basics Quiz
Quiz
•
10th Grade
10 questions
APCSA - Unit 3
Quiz
•
9th - 12th Grade
15 questions
Character Analysis
Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
10 questions
American Flag
Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25
Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
20 questions
Taxes
Quiz
•
9th - 12th Grade
17 questions
Parts of Speech
Quiz
•
7th - 12th Grade
20 questions
Chapter 3 - Making a Good Impression
Quiz
•
9th - 12th Grade
20 questions
Inequalities Graphing
Quiz
•
9th - 12th Grade
10 questions
Identifying equations
Quiz
•
KG - University