Computer Science Principles Midterm

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Consider the following code segment. j=1 Repeat until <MISSING CONDITION> j=j+2 Which of the following replacements for <MISSING CONDITION> will result in an infinite loop? (A) j=6 (B) j >=6 (C) j=7 (D) j>7

(A) j=6

The procedure Draw (length, direction) is used to draw a line segment length units long in a given direction (left, right, up, or down), starting at the current cursor position. The cursor is then repositioned at the end of the line segment that was drawn. Consider the following program, where the cursor starts in the upper left corner of a grid of dots. The dots are spaced one unit apart. Draw (1, right) Draw (2, down) Draw (1, left) Draw (1, right) Draw (1, up) Draw (1, left) Which of the following represents the figure that is drawn by the program? (A) (B) (C) (D)

(B) (The one that looks like a 3)

A programmer is writing a program that is intended to be able to process large amounts of data. Which of the following considerations is LEAST likely to affect the ability of the program to process larger data sets? (A) How long the program takes to run (B) How many programming statements the program contains (C) How much memory the program requires as it runs (D) How much storage space the program requires as it runs

(B) How many programming statements the program contains

What is the minimum number of connections that must be broken or removed in the network before computer E can no longer communicate with computer F? (A) 1 (B) 2 (C) 3 (D) 4

(C) 3

ASCII is a character-encoding scheme that uses 7 bits to represent each character. The decimal (base 10) values 65 through 90 represent the capital letters A through Z, as shown in the table below. What ASCII character is represented by the binary(base 2) number 1001010 ? (A) H (B) I (C) J (D) K

(C) J (its 74)

Which of the following activities poses the greatest personal cybersecurity risk? (A) Making a purchase at an online store that uses public key encryption to transmit credit card information (B) Paying a bill using a secure electronic payment system (C) Reserving a hotel room by e-mailing a credit card number to a hotel (D) Withdrawing money from a bank account using an automated teller machine (ATM)

(C) Reserving a hotel room by e-mailing a credit card number to a hotel

The code fragment below is intended to display "odd" if the positive number num is odd. If <Missing condition> display "odd" Which of the following can be used to replace <MISSING CONDITION> so that the code fragment will work as intended? (A) (num MOD 1) = 0 (B) (num MOD 1) = 1 (C) (num MOD 2) = 0 (D) (num MOD 2) = 1

(D) (num MOD 2) = 1 (remember that Mod is divide and the answer is the remainder)

A new bank plans to make customer convenience a prioritybyminimizing the amount of time a customer waits in line. The bank is considering two options: a single line where the customer at the front waits for the next available teller, or separate lines for each teller. The bank decides to use a computer simulation of these two options to determine the average wait time for customers. Which of the following is NOT true about the bank's plan? (A) The bank can incorporate other factors, such as the number of tellers, in the simulation. (B) The bank can use the simulation to investigate these two options without causing inconvenience for customers. (C) The bank mayconsider new alternatives based on the simulation results. (D) The simulation will not produce usable results because actual customer data are not available.

(D) The simulation will not produce usable results because actual customer data are not available.

The algorithm below is used to simulate the results of flipping a coin 4 times. Consider the goal of determining whether the simulation resulted in an equal number of heads and tails. Step 1 : Initialize the variables heads_counterand flip_counterto 0. Step 2 : A variable coin_flipis randomlyassigned a value of either 0 or 1. If coin_fliphas the value 0, the coin flip result is heads, so heads_counteris incremented by 1. Step 3 : Increment the value of flip_counterby 1. Step 4 : Repeat steps 2 and 3 until flip_counterequals 4. Following execution of the algorithm, which of the following expressions indicates that the simulation resulted in an equal number of heads and tails? (A) coin_flip=1 (B) flip_counter=1 (C) flip_counter=2 (D) heads_counter=2

(D) heads_counter=2

9. A programmer wrote the program below. The program uses a list of numbers called numList. The program is intended to display the sum of the numbers in the list. In order to test the program, the programmer initializes numList to [0, 1, 4, 5]. The program displays 10, and the programmer concludes that the program works as intended. Which of the following is true? (A) The conclusion is correct; the program works as intended. (B) The conclusion is incorrect; the program does not display the correct value for the test case [0, 1, 4, 5]. (C) The conclusion is incorrect; using the test case [0, 1, 4, 5] is not sufficient to conclude the program is correct. (D) The conclusion is incorrect; using the test case [0, 1, 4, 5] only confirms that the program works for lists in increasing order.

c) The conclusion is incorrect; using the test case [0, 1, 4, 5] is not sufficient to conclude the program is correct.

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.

Consider the following program, which is intended to display the number of times a number target appears in a list. Count=0 For each n IN list if n=target count=count+1 Display Count Which of the following best describes the behavior of the program? (A) The program correctly displays the number of times target appears in the list. (B) The program does not workas intended when target does not appear in the list. (C) The program does not workas intended when target appears in the list more than once. (D) The program does not workas intended when target appears as the last element of the list.

(A) The program correctly displays the number of times target appears in the list.

A student is recording a song on her computer. When the recording is finished, she saves a copy on her computer. The student notices that the saved copy is of lower sound quality than the original recording. Which of the following could be a possible explanation for the difference in sound quality? (A) The song was saved using fewer bits per second than the original song. (B) The song was saved using more bits per second than the original song. (C) The song was saved using a lossless compression technique. (D) Some information is lost every time a file is saved from one location on a computer to another location.

(A) The song was saved using fewer bits per second than the original song.

3. Which of the following best explains what happens when a new device is connected to the Internet? (A) A device driver is assigned to the device. (B) An Internet Protocol (IP) address is assigned to the device (C) A packet number is assigned to the device. (D) A Web site is assigned to the device.

(B) An Internet Protocol (IP) address is assigned to the device.

Some programming languages use constants, which are variables that are initialized at the beginning of a program and never changed. Which of the following are good uses for a constant? I. To represent the mathematical value (pi) as 3.14 II. To represent the current score in a game III. To represent a known value such as the number of days in a week (A) I and II only (B) I and III only (C) II and III only (D) I, II, and III

(B) I and III only

Which of the following statements about security in the network is true? I. Computers A and D need to communicate with at least two additional computers in the network in order to communicate with each other. II. Computers B and C can communicate with each other without additional computers being aware of the communication. (A) I only (B) II only (C) I and II (D) Neither I nor II

(B) II only

The code segment below uses the procedure IsFound (list, item), which returns true if item appears in list and returns false otherwise. The list resultList is initially empty. FOR EACH item IN inputList1 { IF (IsFound (inputList2, item) { APPEND (resultList, item) } } Which of the following best describes the contents of resultList after the code segment is executed? (A) All elements in inputList1 followed by all elements in inputList2 (B) Only elements that appear in both inputList1 and inputList2 (C) Only elements that appear in either inputList1 or inputList2 but not in both lists (D) Only elements that appear in inputList1 but not in inputList2

(B) Only elements that appear in both inputList1 and inputList2

A cable television company stores information about movie purchases made by subscribers. Each day, the following information is summarized and stored in a publicly available database. • The day and date each movie was purchased • The title of each movie purchased • The cities where subscribers purchased each movie • The number of times each movie was purchased by subscribers in a given city A sample portion of the database is shown below. The database is sorted by date and movie title. Day and Date Movie Title City Number of Times Purchased Sat 01 / 05 / 2014 Movie A Houston, Texas 1 Sat 01 / 05 / 2014 Movie A Detroit, Michigan 2 Sat 01 / 05 / 2014 Movie B Houston, Texas 1 Sat 01 / 05 / 2014 Movie C Anchorage, Alaska 1 Sun 01 / 06 / 2014 Movie A Wichita, Kansas 3 Which of the following CANNOT be determined using only the information in the database? (A) The date when a certain movie was purchased the greatest number of times (B) The number of movies purchased by an individual subscriber for a particular month (C) The total number of cities in which a certain movie was purchased (D) The total number of movies purchased in a certain city during a particular month

(B) The number of movies purchased by an individual subscriber for a particular month

Central High School keeps a database of information about each student, including the numeric variables numberOfAbsences and gradePointAverage. The expression below is used to determine whether a student is eligible to receive an academic award. (numberOfAbsences ≤ 5) AND (gradePointAverage > 3.5) Which of the following pairs of values indicates that a student is eligible to receive an academic award? (A) numberOfAbsences = 3, gradePointAverage = 3.5 (B) numberOfAbsences = 5, gradePointAverage = 3.8 (C) numberOfAbsences = 6, gradePointAverage = 3.4 (D) numberOfAbsences = 6, gradePointAverage = 3.6

(B) numberOfAbsences = 5, gradePointAverage = 3.8

Computers are often used to search through large sets of data to find useful patterns in the data. Which of the following tasks is NOT an example where searching for patterns is needed to produce useful information? (A) A credit card company analyzing credit card purchases to identify potential fraudulent charges (B) A grocery store analyzing customers' past purchases to suggest new products the customer may be interested in (C) A high school analyzing student grades to identify the students with the top ten highest grade point averages (D) An online retailer analyzing customers' viewing habits to suggest other products based on the purchasing history of other customers

(C) A high school analyzing student grades to identify the students with the top ten highest grade point averages

An algorithm has been developed to compute the sum of all the elements in a list of integers. Which of the following programming structures must be added to the existing algorithm so that the new algorithm computes the sum of onlythe even integers in the list? (A) Iteration (B) Searching (C) Selection (D) Sequencing

(C) Selection

Which of the following statements are true about using a high-level programming language instead of a lower-level language? I. Programs written in a high-level language are generally easier for people to read than programs written in a low-level language. II. A high-level language provides programmers with more abstractions than a low-level language. III. Programs written in a high-level language are generally easier to debug than programs written in a low-level language. (A) I only (B) I and III only (C) II and III only (D) I, II, and III

(D) I, II, and III

Which of the following is a true statement about program documentation? (A) Program documentation should not be changed after it is first written. (B) Program documentation is only needed for programs in development; it is not needed after a program is completed. (C) Program documentation is useful when programmers collaborate but not when a programmer works individually on a project. (D) Program documentation is useful during initial program development and also when modifications are made to existing programs

(D) Program documentation is useful during initial program development and also when modifications are made to existing programs

The question below uses a robot in a grid of squares. The robot is represented as a triangle, which is initiallyin the bottom-left square of the grid and facing toward the top of the grid. Code for the procedure Mystery is shown below. Assume that the parameter p has been assigned a positive integer value (e.g., 1, 2, 3, ...). Which of the following shows a possible result of calling the procedure? a) b) c) d)

A) (its facing left)

A flowchart is a way to visually represent an algorithm. The flowchart below uses the following building blocks. count=1 Repeat until count is equal to or greater than 5 { if count<5 then count=count+1} Display (count) What is displayed as a result of executing the algorithm in the flowchart? (A) 5 (B) 15 (C) 1234 (D) 12345

A) 5

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

Which of the following is considered an unethical use of computer resources? (A) Downloading freeware or shareware onto your home computer (B) Purchasing a game from an app store and downloading it directly to a mobile device (C) Purchasing a single-user copy of photo editing software and installing it on all the computers in a computer lab (D) Searching online for an electronic version of a school textbook

C) Purchasing a single-user copy of photo editing software and installing it on all the computers in a computer lab

Which of the following is LEAST likely to indicate a phishing attack? (A) An e-mail from your bank asks you to call the number on your card to verify a transaction (B) An e-mail from a merchant asks that you click on a link to reset your password (C) An e-mail from a utility company asks you to enter your date of birth and social security number for verification purposes (D) An e-mail indicates that you have won a large sum of money and asks you to enter your bank account number so that the money can be transferred to you

(A) An e-mail from your bank asks you to call the number on your card to verify a transaction

Consider the code segment below. Line 1: IF (a = 0) Line 2: { Line 3: b=a+1 Line 4: } Line 5: ELSE Line 6: { Line 7: b= a+2 Line 8: } Which of the following changes will NOT affect the results when the code segment is executed? (A) Changing line 3 to b=10 (B) Changing line 3 to a=b+10 (C) Changing line 7 to b=30 (D) Changing line 7 to a=b+20

(A) Changing line 3 to b=10

In the program below, the initial value of x is 5 and the initial value of y is 10. IF (x<0) Display "Foxtrot" else if (x>y) display "Hotel" else if (y>0) display "November" else display "Yankee" What is displayed as a result of running the program? (A) Foxtrot (B) Hotel (C) November (D) Yankee

(C) November


Ensembles d'études connexes

mutually exclusive and independent events

View Set

International Marketing Exam 4 (2)

View Set

Intro to Criminal Justice Chapter 10

View Set

Testout Chapter 1 Linux Admin Midterm 2.19.19 1.1-1.11 10.3 7.9 2.3 6.1-6.3 9.1-9.3

View Set

Black Book: Reading RIGHT and WRONG Answers (p64-69)

View Set

Chapter 11 Push/Pull Factors and Reasons

View Set

10. Environmental Policy Instruments

View Set