0% found this document useful (0 votes)
8 views10 pages

3.5 Boolean Expressions Questions

The document is a test booklet for AP Computer Science Principles focusing on Boolean expressions and logic gates. It contains multiple-choice questions that assess understanding of algorithms, logic gate functions, and Boolean expressions in various scenarios. The questions range from evaluating expressions to determining eligibility based on given criteria.

Uploaded by

laythshadid.5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views10 pages

3.5 Boolean Expressions Questions

The document is a test booklet for AP Computer Science Principles focusing on Boolean expressions and logic gates. It contains multiple-choice questions that assess understanding of algorithms, logic gate functions, and Boolean expressions in various scenarios. The questions range from evaluating expressions to determining eligibility based on given criteria.

Uploaded by

laythshadid.5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

AP COMPUTER SCIENCE PRINCIPLES Test Booklet

3.5: Boolean Expressions

1. Directions: The question or incomplete statement below is followed by four suggested answers or
completions. Select the one that is best in each case.

A flowchart is a way to visually represent an algorithm. The flowchart below is used by an apartment rental Web
site to set the variable to for apartments that meet certain criteria.

Which of the following statements is equivalent to the algorithm in the flowchart?

AP Computer Science Principles Page 1 of 10


Test Booklet

3.5: Boolean Expressions

(A)

(B)

(C)

(D)

2. Directions: The question or incomplete statement below is followed by four suggested answers or
completions. Select the one that is best in each case.

A gate is a type of logic gate that produces an output of only when both of its two inputs are
. Otherwise, the gate produces an output of . Which of the following Boolean expressions correctly
models a gate with inputs and ?

(A)

(B)

(C)

(D)

3. An office building has two floors. A computer program is used to control an elevator that travels between the two
floors. Physical sensors are used to set the following Boolean variables.

The elevator moves when the door is closed and the elevator is called to the floor that it is not currently on. Which
of the following Boolean expressions can be used in a selection statement to cause the elevator to move?
(A) (onFloor1 AND callTo2) AND (onFloor2 AND callTo1)
(B) (onFloor1 AND callTo2) OR (onFloor2 AND callTo1)
(C) (onFloor1 OR callTo2) AND (onFloor2 OR callTo1)
(D) (onFloor1 OR callTo2) OR (onFloor2 OR callTo1)

Page 2 of 10 AP Computer Science Principles


Test Booklet

3.5: Boolean Expressions

4. The following table shows the value of expression based on the values of input1 and input2.

Value of input1 Value of input2 Value of expression


true true false
true false true
false true true
false false true

Which of the following expressions are equivalent to the value of expression as shown in the table?

Select two answers.

A (NOT input1) OR (NOT input2)

B (NOT input1) AND (NOT input2)

C NOT (input1 OR input2)

D NOT (input1 AND input2)

5. Directions: For the question or incomplete statement below, two of the suggested answers are correct. For
this question, you must select both correct choices to earn credit. No partial credit will be earned if only one
correct choice is selected. Select the two that are best in each case.

Which of the following Boolean expressions are equivalent to the expression

Select two answers.

AP Computer Science Principles Page 3 of 10


Test Booklet

3.5: Boolean Expressions

6. The diagram below shows a circuit composed of two logic gates labeled OR and AND. Each gate takes two inputs
and produces a single output.

If the inputs A and C are both true, which of the following best describes the output of the AND gate?
(A) The output will be true no matter what the value of input B is.
(B) The output will be false no matter what the value of input B is.
(C) The output will be true if input B is true; otherwise it will be false.
(D) The output will be false if input B is true; otherwise it will be true.

7. A programmer wants to determine whether a score is within 10 points of a given target. For example, if the target is
50, then the scores 40, 44, 50, 58, and 60 are all within 10 points of the target, while 38 and 61 are not.

Which of the following Boolean expressions will evaluate to true if and only if score is within 10 points
of target ?
(A) (score ≤ target + 10) AND (target + 10 ≤ score)
(B) (target + 10 ≤ score) AND (score ≤ target - 10)
(C) (score ≤ target - 10) AND (score ≤ target + 10)
(D) (target - 10 ≤ score) AND (score ≤ target + 10)

Page 4 of 10 AP Computer Science Principles


Test Booklet

3.5: Boolean Expressions

8. Directions: The question or incomplete statement below is followed by four suggested answers or
completions. Select the one that is best in each case.

The diagram below shows a circuit composed of three logic gates. Each gate takes two inputs and produces a single
output.

For which of the following input values will the circuit have an output of ?

(A)
(B)

(C)

(D)

9. 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?
(A) val1 = true, val2 = true
(B) val1 = true, val2 = false
(C) val1 = false, val2 = true
(D) val1 = false, val2 = false

10. To be eligible for a particular ride at an amusement park, a person must be at least 12 years old and must be
between 50 and 80 inches tall, inclusive.

Let age represent a person’s age, in years, and let height represent the person’s height, in inches. Which of
the following expressions evaluates to true if and only if the person is eligible for the ride?

AP Computer Science Principles Page 5 of 10


Test Booklet

3.5: Boolean Expressions

(A) (age ≥ 12) AND ((height ≥ 50) AND (height ≤ 80))


(B) (age ≥ 12) AND ((height ≤ 50) AND (height ≥ 80))
(C) (age ≥ 12) AND ((height ≤ 50) OR (height ≥ 80))
(D) (age ≥ 12) OR ((height ≥ 50) AND (height ≤ 80))

11. 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?
(A) ((age ≥ 13) OR (grade ≥ 9)) AND (age ≤ 18)
(B) ((age ≥ 13) OR (grade ≥ 9)) AND (age < 18)
(C) ((age ≥ 13) OR (grade ≥ 9)) OR (age ≤ 18)
(D) ((age ≥ 13) OR (grade ≥ 9)) OR (age < 18)

12. 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)?
(A) n = (n MOD 100)
(B) (n ≥ 10) AND (n < 100)
(C) (n < 10) AND (n ≥ 100)
(D) (n > 10) AND (n < 99)

A large spreadsheet contains the following information about local restaurants. A sample portion of the spreadsheet is
shown below.

C D E
A B
Number of Average Accepts
Restaurant Name Price Range
Customer Ratings Customer Rating Credit Cards
1 Joey Calzone’s Pizzeria lo 182 3.5 false
2 78th Street Bistro med 41 4.5 false
3 Seaside Taqueria med 214 4.5 true
4 Delicious Sub Shop II lo 202 4.0 false
5 Rustic Farm Tavern hi 116 4.5 true
6 ABC Downtown Diner med 0 -1.0 true

In column B, the price range represents the typical cost of a meal, where "lo" indicates under $10, "med" indicates
$11 to $30, and "hi" indicates over $30.
In column D, the average customer rating is set to -1.0 for restaurants that have no customer ratings.

Page 6 of 10 AP Computer Science Principles


Test Booklet

3.5: Boolean Expressions

13. A student wants to count the number of restaurants in the spreadsheet whose price range is $30 or less and whose
average customer rating is at least 4.0. For a given row in the spreadsheet, suppose prcRange contains the
price range as a string and avgRating contains the average customer rating as a decimal number.

Which of the following expressions will evaluate to true if the restaurant should be counted and evaluates
to false otherwise?
(A) (avgRating ≥ 4.0) AND ((prcRange = "lo") AND (prcRange = "med"))
(B) (avgRating ≥ 4.0) AND ((prcRange = "lo") OR (prcRange = "med"))
(C) (avgRating ≥ 4.0) OR ((prcRange = "lo") AND (prcRange = "med"))
(D) (avgRating ≥ 4.0) OR ((prcRange = "lo") OR (prcRange = "med"))

14. 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?
(A) (overallGPA > 3.0) AND (scienceGPA > 3.2)
(B) (overallGPA > 3.0) AND (scienceGPA ≥ 3.2)
(C) (overallGPA ≥ 3.0) AND (scienceGPA > 3.2)
(D) (overallGPA ≥ 3.0) AND (scienceGPA ≥ 3.2)

15. Assume that the Boolean variable hot is assigned the value true and the Boolean variable humid is
assigned the value false. Which of the following will display the value true ?

Select two answers.

AP Computer Science Principles Page 7 of 10


Test Booklet

3.5: Boolean Expressions

16. The diagram below shows a circuit composed of three logic gates. Each gate takes two inputs and produces a single
output.

For which of the following input values will the circuit have an output of true ?
(A) A = true, B = true, C = true, D = false
(B) A = true, B = false, C = false, D = true
(C) A = false, B = true, C = true, D = true
(D) A = false, B = false, C = true, D = true

Page 8 of 10 AP Computer Science Principles


Test Booklet

3.5: Boolean Expressions

17. In a certain country, a person must be at least 16 years old to drive a car and must be at least 18 years old to vote.
The variable age represents the age of a person as an integer.

Which of the following expressions evaluates to true if the person is old enough to drive but not old enough to
vote, and evaluates to false otherwise?

I. (age ≥ 16) AND (age ≤ 18)


II. (age ≥ 16) AND (NOT(age ≥ 18))
III. (age < 18) AND (NOT(age < 16))
(A) II only
(B) I and II only
(C) I and III only
(D) II and III only

18. The figure below shows a circuit composed of two logic gates. The output of the circuit is true.

Which of the following is a true statement about input A?


(A) Input A must be true.
(B) Input A must be false.
(C) Input A can be either true or false.
(D) There is no possible value of input A that will cause the circuit to have the output true.

AP Computer Science Principles Page 9 of 10


Test Booklet

3.5: Boolean Expressions

19. 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?


(A) 70000
(B) 80000
(C) true
(D) false

20. Consider the following code segment.

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


(A) true true true
(B) false false false
(C) true false true
(D) false false true

Page 10 of 10 AP Computer Science Principles

You might also like