AP Computer Science Principles Unit 4 AP Review

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

A string variable named studentName and a Boolean variable named isAbsent

A teacher is writing a code segment that will use variables to represent a student's name and whether or not the student is currently absent. Which of the following variables are most appropriate for the code segment?

When the value of exam is 80 and the value of presentation is 60

Consider the following code segment, where exam and presentation are integer variables and grade is a string variable. IF((exam > 90) AND (presentation > 80)) { grade ← "A" } IF((exam > 80) OR (presentation > 75)) { grade ← "B" } ELSE { IF((exam > 70) OR (presentation > 60)) { grade ← "C" } ELSE { IF(exam > 60) { grade ← "D" } ELSE { grade ← "F" } } } Under which of the following conditions will the value "C" be assigned to the variable grade ?

-2

If the value of x is 3 and the value of y is 5, what is displayed as a result of executing the code segment?

THREE

If x has a value of 7 and y has a value of 20, what is displayed as a result of executing the code segment?

IF(score > 100) { bonus ← score * 10 } ELSE { IF(score ≥ 50) { bonus ← score } ELSE { bonus ← 0 } } AND { bonus ← score * 10 } ELSE { bonus ← score } }

In a certain game, the integer variable bonus is assigned a value based on the value of the integer variable score. If score is greater than 100, bonus is assigned a value that is 10 times score. If score is between 50 and 100 inclusive, bonus is assigned the value of score. If score is less than 50, bonus is assigned a value of 0. Which of the following code segments assigns bonus correctly for all possible integer values of score ?

true

In the following expression, the variable truckWeight has the value 70000 and the variable weightLimit has the value 80000. truckWeight < weightLimit What value does the expression evaluate to?

(n ≥ 10) AND (n < 100)

Let n be an integer value. Which of the following expressions evaluates to true if and only if n is a two-digit integer (i.e., in the range from 10 to 99, inclusive)?

F

T && F =

T

T && T =

T

T II F =

val1 = false, val2 = false

The following code segment is used to determine whether a customer is eligible for a discount on a movie ticket. val1 ← (NOT (category = "new")) OR (age ≥ 65) val2 ← (category = "new") AND (age < 12) If category is "new" and age is 20, what are the values of val1 and val2 as a result of executing the code segment?

number

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

The variable isOpen is to be used to indicate whether or not a store is currently open. Which of the following is the most appropriate data type for isOpen ?

((age ≥ 13) OR (grade ≥ 9)) AND (age < 18)

To attend a particular camp, a student must be either at least 13 years old or in grade 9 or higher, but must not yet be 18 years old. Let age represent a student's age and let grade represent the student's grade level. Which of the following expressions evaluates to true if the student is eligible to attend the camp and evaluates to false otherwise?

(overallGPA ≥ 3.0) AND (scienceGPA > 3.2)

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?

The value of first is true, and the value of second is true.

What are the values of first and second as a result of executing the code segment?

21 40 30 50

What is displayed as a result of executing the code segment?

false false false

What is displayed as a result of executing the code segment?

20

What is the value of r as a result of executing the code segment?

The program will be easier for people to read and the program will be easier to modify

Which of the following are benefits of using well-named variables in a computer program?

temp ← word1 word1 ← word3 word3 ← temp

Which of the following code segments can be used to update the values of the variables as shown in the table?

3

Which of the following initial values of the variable y would result in the variable z being set to 2 after the code segment is executed?

x and z only

Which of the variables have the value 50 after executing the code segment?

5

result ← 1 IF(score1 > 500) { result ← result + 1 IF(score2 > 500) { result ← result + 1 } ELSE { result ← result + 2 } } ELSE { result ← result + 5 IF(score2 > 500) { result ← result + 1 } ELSE { result ← result - 1 } } If the value of score1 is 350 and the value of score2 is 210, what will be the value of result after the code segment is executed?

16

what is the value of sum after the code segment is executed


संबंधित स्टडी सेट्स

SOCI 101 InQuisitive Ch.17 - Science, the Environment, and Society

View Set

Plant Diseases: http://www.ipm.ucdavis.edu/PMG/menu.disease.html

View Set

Chapter 19: Evaluation and Management

View Set

California Real Estate Exam Multiple Choice Questions

View Set