Unit 4 Turn In

¡Supera tus tareas y exámenes ahora con Quizwiz!

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 ? A Boolean B number C string D list

A Boolean

A school library allows students to borrow laptops. A computer program is used to count the number of times a particular laptop has been borrowed from the library and the number of times the same laptop has been returned to the library . Which of the following indicate that a particular laptop is not currently borrowed? Select two answers. A The difference between and is zero. B The product of and is a positive even number. C The quotient when is divided by is greater than 1. D The sum of and is a positive even number.

A The difference between and is zero. D The sum of and is a positive even number.

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)

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

A certain game keeps track of the maximum and minimum scores obtained so far. If num represents the most recent score obtained, which of the following algorithms correctly updates the values of the maximum and the minimum? A If num is greater than the minimum, set the minimum equal to num. Otherwise, if num is greater than the maximum, set the maximum equal to num. B If num is less than the minimum, set the minimum equal to num. Otherwise, if num is greater than the maximum, set the maximum equal to num. C If num is less than the minimum, set the minimum equal to num. Otherwise, if num is less than the maximum, set the maximum equal to num. D If num is greater than the minimum, set the minimum equal to num. Otherwise, if num is less than the maximum, set the maximum equal to num.

B If num is less than the minimum, set the minimum equal to num. Otherwise, if num is greater than the maximum, set the maximum equal to num.

Which of the following are benefits of using well-named variables in a computer program? Select two answers. A The program will run faster. B The program will be easier for people to read. C The program will have a greater data storage capacity. D The program will be easier to modify in the future.

B The program will be easier for people to read. D The program will be easier to modify in the future.

Consider the following code segment, which uses the variables r, s, and t. r ← 1 s ← 2 t ← 3 r ← s s ← t DISPLAY (r) DISPLAY (s) What is displayed as a result of running the code segment? A 1 1 B 1 2 C 2 3 D 3 2

C 2 3

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? A A string variable named s and a Boolean variable named a B A string variable named s and a numeric variable named n C A string variable named studentName and a Boolean variable named isAbsent D A string variable named studentName and a numeric variable named numAbsences

C A string variable named studentName and a Boolean variable named isAbsent

A programmer completes the user manual for a video game she has developed and realizes she has reversed the roles of goats and sheep throughout the text. Consider the programmer's goal of changing all occurrences of "goats" to "sheep" and all occurrences of "sheep" to "goats." The programmer will use the fact that the word "foxes" does not appear anywhere in the original text. Which of the following algorithms can be used to accomplish the programmer's goal? A First, change all occurrences of "goats" to "sheep." Then, change all occurrences of "sheep" to "goats." B First, change all occurrences of "goats" to "sheep." Then, change all occurrences of "sheep" to "goats." Last, change all occurrences of "foxes" to "sheep." C First, change all occurrences of "goats" to "foxes." Then, change all occurrences of "sheep" to "goats." Last, change all occurrences of "foxes" to "sheep." D First, change all occurrences of "goats" to "foxes." Then, change all occurrences of "foxes" to "sheep." Last, change all occurrences of "sheep" to "goats."

C First, change all occurrences of "goats" to "foxes." Then, change all occurrences of "sheep" to "goats." Last, change all occurrences of "foxes" to "sheep."

A programmer is creating an algorithm that will be used to turn on the motor to open the gate in a parking garage. The specifications for the algorithm are as follows. The gate should not open when the time is outside of business hours. The motor should not turn on unless the gate sensor is activated. The motor should not turn on if the gate is already open. Which of the following algorithms can be used to open the gate under the appropriate conditions? A Check if the time is outside of business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is closed. If it is, turn on the motor. B Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is open. If it is, turn on the motor. C Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is not, check if the gate is open. If it is not, turn on the motor. D Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is open. If it is not, turn on the motor.

D Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is open. If it is not, turn on the motor.

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

D II and III only

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

D val1 = false, val2 = false


Conjuntos de estudio relacionados

World History A: Unit 1 - Study Set for quiz 1

View Set

Financial Analysis - USCA MBA - Ch5 HW

View Set

CH 7: Positive organizational behavior

View Set

Chapter 18: European Power and Expansion

View Set

Chapter 10: Corporate Level Strategy: Related and Unrelated Diversification

View Set