CSP Final studyset Unit 4 test

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

What number will be output by the console.log command on line 7?

100

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?

2 3

Consider the following code segment. What is the value of r as a result of executing the code segmen q<-----20

20

x<---20

21,40,30,50

Internet protocol version 4 (IPv4) represents each IP address as a 32-bit binary number. Internet protocol version 6 (IPv6) represents each IP address as a 128-bit binary number. Which of the following best describes the result of using 128-bit addresses instead of 32-bit addresses?

2^96

Consider the following code segment. 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?

3

What text will be output by the program? score= score + 10

30 or more

An office uses an application to assign work to its staff members. The application uses a binary sequence to represent each of 100 staff members. What is the minimum number of bits needed to assign a unique bit sequence to each staff member?

7

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.

A The output will be true no matter what the value of input B is.

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 ? (ALL)

A=true B=false C=False D=False

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)

B (n ≥ 10) AND (n < 100)

Which of the following Boolean expressions are equivalent to the expression num>=15 Select two answers.

B num>15 or num=15 C not num<15

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)

D (target - 10 ≤ score) AND (score ≤ target + 10)

A numeric test score is to be converted to a letter grade of A, B, or C according to the following rules: A score greater than 90 is considered an A; a score between 80 and 90, inclusive, is considered a B; and any other score is considered a C. Which of the following code segments will assign the correct letter grade to grade based on the value of the variable score ?

II and III only

"You win!" never displays. What change would fix this issue?

Line 3 - remove var

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?

True

ASCII is a character-encoding scheme that uses a numeric value to represent each character. For example, the uppercase letter "G" is represented by the decimal (base 10) value 71. A partial list of characters and their corresponding ASCII values are shown in the table below. ASCII characters can also be represented by hexadecimal numbers. According to ASCII character encoding, which of the following letters is represented by the hexadecimal (base 16) number 56?

V

What will be the order of letters printed to the console when this program is run?

a b c b c

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 ticket prices at a movie theater are given below. A programmer is creating an algorithm to set the value of based on the information in the table. The programmer uses the integer variable for the age of the moviegoer. The Boolean variable is when the movie is 3-D and otherwise. Which of the following code segments correctly sets the value of ?

if is 3D ticket price<------ ticket price + 5

The cost of a customer's electricity bill is based on the number of units of electricity the customer uses. For the first 25 units of electricity, the cost is $5 per unit. For units of electricity after the first 25, the cost is $7 per unit. Which of the following code segments correctly sets the value of the variable cost to the cost, in dollars, of using numUnits units of electricity?

numUnits<=25 numUnits*5 25*5+(numUnits-25)*7

In the following code segment, assume that the variable n has been initialized with an integer value. Which of the following is NOT a possible value displayed by the program?

"carrot"

The code fragment below is intended to display "odd" if the positive number num is odd. Which of the following can be used to replace <MISSING CONDITION> so that the code fragment will work as intended?

(num MOD 2) = 1

Consider the following code segment. 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?

-2

Consider the following code segment. What is the value of sum after the code segment is executed? num1<------6

16

What number will be output by the console.log command on line 5?

16

Consider the following code segment. 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?

5

A student is writing a program to model different real-world events using simulations. Which of the following simulations will generate a result that would best be stored using a Boolean variable? A A simulation of flipping a fair coin B A simulation of rolling a fair die (with sides numbered 1 through 6) C A simulation of the temperature in a location over time D A simulation of traffic patterns on a road

A A simulation of flipping a fair coin

Which of the following best explains how data is typically assembled in packets for transmission over the Internet? A Each packet contains data to be transmitted, along with metadata containing information used for routing the data. B Each packet contains an encrypted version of the data to be transmitted, along with metadata containing the key needed to decrypt the data. C Each packet contains only the metadata used to establish a direct connection so that the data can be transmitted. D Each packet contains multiple data files bundled together, along with metadata describing how to categorize each data file.

A Each packet contains data to be transmitted, along with metadata containing information used for routing the data.

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 ? Select TWO answers. A IF(score > 100) { bonus ← score * 10 } ELSE { IF(score ≥ 50) { bonus ← score } ELSE { bonus ← 0 } } B IF(score ≥ 50) { IF(score > 100) { bonus ← score * 10 } ELSE { bonus ← 0 } } ELSE { bonus ← score } C IF(score < 50) { bonus ← 0 } ELSE { IF(score ≥ 50) { bonus ← score } ELSE { bonus ← score * 10 } } D IF(score < 50) { bonus ← 0 } ELSE { IF(score > 100) { bonus ← score * 10 } ELSE { bonus ← score } }

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

A user enters a Web address in a browser, and a request for a file is sent to a Web server. Which of the following best describes how the file is sent to the user? A The file is broken into packets for transmission. The packets must be reassembled upon receipt. B The file is broken into packets for transmission. The user's browser must request each packet in order until all packets are received. C The server attempts to connect directly to the user's computer. If the connection is successful, the entire file is sent. If the connection is unsuccessful, an error message is sent to the user. D The server repeatedly attempts to connect directly to the user's computer until a connection is made. Once the connection is made, the entire file is sent.

A The file is broken into packets for transmission. The packets must be reassembled upon receipt.

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.

Ticket prices for a science museum are shown in the following table. Type of TicketGeneral Admission Cost(in dollars)Guided Tour Cost(in dollars)Regular (ages 13 and up)810Child (ages 12 and below)68 A programmer is creating an algorithm to display the cost of a ticket based on the information in the table. The programmer uses the integer variable age for the age of the ticket recipient. The Boolean variable includesTour is true when the ticket is for a guided tour and is false when the ticket is for general admission. Which of the following code segments correctly displays the cost of a ticket? A cost ← 6 IF ((age > 12) OR includesTour) { cost ← cost + 2 } DISPLAY (cost) B cost ← 6 IF (age > 12) { cost ← cost + 2 } IF (includesTour) { cost ← cost + 2 } DISPLAY (cost) C cost ← 6 IF (age > 12) { IF (includesTour) { cost ← cost + 2 } } DISPLAY (cost) D cost ← 6 IF (age > 12) { cost ← cost + 2 } ELSE

B cost ← 6 IF (age > 12) { cost ← cost + 2 } IF (includesTour) { cost ← cost + 2 } DISPLAY (cost)

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 certain programming language uses 4-bit binary sequences to represent nonnegative integers. For example, the binary sequence 0101 represents the corresponding decimal value 5. Using this programming language, a programmer attempts to add the decimal values 14 and 15 and assign the sum to the variable total. Which of the following best describes the result of this operation? A The correct sum of 29 will be assigned to the variable total. B An overflow error will occur because 4 bits is not large enough to represent either of the values 14 or 15. C An overflow error will occur because 4 bits is not large enough to represent 29, the sum of 14 and 15. D A round-off error will occur because the decimal values 14 and 15 are represented as approximations due to the fixed number of bits used to represent numbers.

C An overflow error will occur because 4 bits is not large enough to represent 29, the sum of 14 and 15.

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" } } } A When the value of exam is 70 and the value of presentation is 50 B When the value of exam is 70 and the value of presentation is 80 C When the value of exam is 80 and the value of presentation is 60 D When the value of exam is 80 and the value of presentation is 80

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

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?

Floor>10 OR bedrooms=3

In the program below, the initial value of x is 5 and the initial value of y is 10. What is displayed as a result of running the program?

November

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 ?

Number

What text will be output by the program? var age=15

Output D

Three teams (Team A, Team B, and Team C) are participating in a trivia contest. Let scoreA represent the number of correct questions for Team A, scoreB represent the number of correct questions for Team B, and scoreC represent the number of correct questions for Team C. Assuming no two teams get the same number of correct questions, which of the following code segments correctly displays the team with the highest number of correct questions?

score A> score C A C B C


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

PEDS Chapter 21 Family Centered Care of the Child During Illness and Hospitalization

View Set

BMS 251 exam 1 practice questions

View Set

Chapter 1 - Intro to Systems Analysis & Design

View Set

Psychotherapy Key Terms: Transtheoretical model

View Set

Unit 3: Interpersonal Communication & Self-Disclosure

View Set