Computer Science Fall Final

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Which would be beneficial when working with sprites and variables in our programs?

Giving meaningful names to sprites and variables so that you and other programmers can easily refer to them throughout the code

Consider the following code segment that allows a customer to request their preferred beverage and size of beverage. What is displayed if the user enters "20" and "coffee"?

Grande coffee

Given the following segment of code, what would be displayed if the age were initialized with a value of 18?

Group 2

Which statements below are true about fixed and variable width encoding? Select two answers:

Variable width encoding must use some sort of delimiter in order to know where one characters stops and another begins and Fixed width encodings are typically longer than a variable width encoding

There is an empty list called Player and an inputted variable called name. If the code were to be run with the inputted values of: Joe Joe Steve Steve Joe , what would be displayed?

1 1 2 3 3

Which value is most likely to be displayed after running the following block of code?

13

Assume that before the program is run, the value of x = 1. What would be displayed at the end?

16

A video-streaming Web site uses 32-bit integers to count the number of times each video has been played. In anticipation of some videos being played more times than can be represented with 32 bits, the Web site is planning to change to 64-bit integers for the counter. Which of the following best describes the result of using 64-bit integers instead of 32-bit integers?

2^32 times as many values can be represented.

According to Moore's Law, increases in technological performance should approximately double every year? If this holds true, how much can performance be expected to increase over 5 years?

32 times as much

Which of the following decimal (base-10) values is equivalent to the binary (base-2) value 101001?

41

What value does the following code segment display?

53

A digital file contains the following binary sequence of 24 bits: 010000110110000101110100 Which of the following types of data might the above sequence represent?

A 24-bit integer value (e.g., 4,153,716) and Three ASCII characters and A 24-bit RGB color value

While writing a program to regulate the speed of a self-driving car, you find that your software sometimes miscalculates the ideal car speed for city streets to be over 1500 MPH (nearly twice the speed of sound) when it should be around 30 MPH. Which of the following strategies would be best to employ in debugging your program?

After each calculation within your program, insert a temporary statement that displays the most recently calculated value. When running your program, compare the displayed values with the expected values to identify where in the program the error is being introduced.

Consider the following two algorithms for determining the tallest person in a group. Algorithm A Step 1: Everybody stands and lines up against the wall. Step 2: One person from those who are standing steps forward. Step 3: One person from those who are standing steps forward. Step 4: The shorter of these two people who stepped forward sits down. Step 5: Repeat steps 3 and 4 until only on person is standing. Step 6: The last person standing is the tallest in the group. Algorithm B Step 1: Everybody stands and lines up against the wall. Step 2: Each standing person pairs up with one other standing person. Step 3: The shorter member of each pair sits down. Step 4: Repeat steps 2 and 3 until only one person is standing. Step 5: The last person standing is the tallest in the group. Which of the following statements is true about these algorithms when applied to a group of 32 people?

Algorithm A is never faster than Algorithm B

Given a list of integers, sequence, and an integer, value, which of the following best describes what the code segment does?

Any items less than value in sequence are removed.

Consider the following code segment designed to find the area of a triangle. A = .5bh Which of the following statements about the above programs is true?

Both programs will work as intended, but Program B is more readable.

Consider the following code segment that is designed to print all numbers from a list of integer values; called grades, that are between 90 and 100, inclusive. Which of the following modifications can be made to the code to allow it to print numbers from a variety of different ranges of values (ex - 70 - 80) and not just 90 - 100?

Before the FOR EACH block, insert two new INPUT/assignment blocks that initialize variables low and high with the values of the lower and upper limits of the desired range. Replace the 90 and 100 in the IF block condition with low and high, respectively.

Consider the following code segment: If the variables 'onTime' and 'absent' both have values of FALSE, what is displayed as a result of running the code?

Better late than never.

Consider the following code segment that is intended to input two integers, x and y, and then display "yes" if and only if x is greater than y and y is less than or equal to 20. Otherwise, it should display "no". Unfortunately, the above code does not perform as intended. Identify two different options that a programmer might choose, either of which will correct the code so that it performs as intended. Select two answers.

Change the condition in the IF block to be: IF x > y AND y ≤ 20 and Swap the two DISPLAY blocks (i.e., DISPLAY "yes", DISPLAY "no")

Which of the following best describes the need for using cryptography in data communications?

Cryptography ensures data is decipherable by the recipient, but not accessible by a third party.

Chad has written the majority of his code in Scratch and is now ready to start thinking of test cases to make sure that his program functions properly and then when issues arise, fix them. This process is known as what?

Debugging

Which of the following are examples of cybersecurity threats that are designed to attack users or computer networks? Select two answers.

Distributed denial of service (DDoS) and Phishing

The local government for a newly developed community would like to begin conducting an annual census to make an accurate count of its current population and gather other relevant demographic information about its residents. The community is currently relatively small and consists of around 500 homes. However, it is growing quickly and expects to have more than 100,000 homes in the next few years. Which of the following plans would be the most practical and most efficient solution for computing an accurate population count, no matter how large the community grows?

Every year, mail a copy of the census form to every home in the community and require that each household complete the form themselves and mail it back to a central office for processing.

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?

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

Moore's Law describes the rate at which the number of transistors on a single chip doubles over time. Which of the following assumptions CANNOT be inferred as a direct consequence of this rate of doubling?

Five years from now, web pages will require less memory (RAM) than today's web pages.

What will be displayed at the end of this block of code?

banana, banana, apple, banana, grape, kiwi, orange

Remember state space refers to the space of all potential possibilities. Which dichotomous questions below will successfully narrow down the entire state space of 'rolling a normal six-sided die' to just 1 outcome?

Is the value on the die odd? Is the value on the die more than 3? Does the value on the die equal 1, 2, 5 or 6?

Consider the following two implementations of the same algorithm, each written in a different language. Language A: Natural Calculate the average daily rainfall for the week (averageRainfall) by adding together the rainfall totals for each of the 7 days (sun, mon, tue, wed, thu, fri, and sat) and dividing the result by 7. Language B: High-level programming averageRainfall ¨ sun + mon + tue + wed + thu + fri + sat / 7 Which of the following statements about these two implementations is true?

Language B is ambiguous because it is unclear whether the sum of all seven of the days is to be divided by 7 (producing the correct daily average) or if only Saturday's rainfall is to be divided by 7 (producing an incorrect daily average).

A large office building has an elevator that carries occupants between any of the building's 10 floors. The basement is referred to as "Level 0" while the topmost floor is "Level 9." The software for the elevator uses a variable, called level, to track the floor number of the elevator's current position. When a person presses a button indicating that the elevator should rise to a higher floor, the following is invoked: What is displayed if the elevator is currently on the 8th floor (level = 7) and the person on the elevator presses a button that says to go up 3 floors (floors = 3)?

Level 8 Level 9 Cannot go up. Level 9

Consider a robot that is initially facing north in a 5-by-5 grid, as shown in the diagram below. A program segment has been written to move the robot to the upper-right corner where it should face west. Starting position (facing north) (middle) Ending position (facing west) (top right) The following program segment in tended to move a robot from the starting position to the ending position as shown above. However, the program segment does not work correctly. Line 1:MOVE_FORWARD () Line 2:MOVE_FORWARD () Line 3: CAN_MOVE (right) Line 4:MOVE_FORWARD () Line 5:MOVE_FORWARD () Line 6: ROTATE_RIGHT () Line 7:ROTATE_LEFT () Line 8:ROTATE_LEFT () Which 2 lines of code in the segment above must be switched in order for the program to correctly move a robot from the starting position to the ending position?

Line 4 and Line 6

Which of the following types of languages is optimized for machine processing and is usually written and expressed as a series of binary digits (e.g., ones and zeros), making it difficult for humans to read and write?

Low level language

A standard deck of playing cards contains 52 cards, with each card being one of four suits: SPADES, HEARTS, CLUBS, and DIAMONDS. Each suit is represented by 13 cards whose values include ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, and KING. Consider the following two algorithms that are intended to find the card representing the "TEN of HEARTS" in a randomly shuffled deck and separate it from the other 51 cards in the deck. Algorithm A Step 1: Pick up the shuffled deck of cards. Step 2: Look at the topmost card in your hands. Step 3: If the card's suit is a HEART, place the card on top of the pile to your left. Step 4: Otherwise, place the card on top of the pile to your right. Step 5: Repeat steps 2 through 4 until you are no longer holding any cards. Step 6: Pick up the cards in the pile to your left. Step 7: Look at the topmost card in your hands. Step 8: If the card's value is a TEN, place all other cards in your hands on top of the pile to your right. Step 9: Otherwise, place the card on top of the pile to your right. Step 10: Repeat steps 7 through 9 until you are holding only one card. Step 11: The only card in your hand is the TEN of HEARTS. Algorithm B Step 1: Pick up the shuffled deck of cards. Step 2: Look at the topmost card in your hands. Step 3: If the card's suit is a HEART or the card's value is a TEN, place all other cards in your hands on top of the pile to your right. Step 4: Otherwise, place the card on top of the pile to your right. Step 5: Repeat steps 2 through 4 until you are holding only one card. Step 6: The only card in your hand is the TEN of HEARTS.

Only Algorithm A will work as intended.

Elsa and her friend Olaf are co-owners of the world's largest ice cream truck, offering their customers the choice of 256 different flavors of ice cream. The truck, which has been built from an 18-wheeled tractor-trailer, houses the 256 tubs of ice cream in the refrigerated trailer. The side of the truck displays a large list of the 256 names of the different flavors, which the customers then name when they place their orders. Business is booming and the duo needs to serve their customers quickly. However, in order to quickly find the right tub of ice cream out of such a large collection, Elsa and Olaf both agree that they need to use an efficient solution. Elsa suggests that they organize the flavors alphabetically while Olaf suggests that they organize the flavors in order from his favorite to his least favorite. Which of the following solutions would allow these ice cream peddlers to find the customers' chosen flavors the most efficiently?

Organize the tubs alphabetically by flavor name and use a binary search algorithm to find the customer's requested flavor.

Which sorting algorithm finds the minimum value, swaps it with the value in the first position, and repeats these steps for the remainder of the list?

Selection

Consider constructing an algorithm for a robot that can only perform the following three predefined operations. MOVE_FORWARD: The robot moves one square forward in the direction it is facing. ROTATE_LEFT: The robot rotates in place 90 degrees counterclockwise (i.e., makes an in-place left turn). ROTATE_RIGHT: The robot rotates in place 90 degrees clockwise (i.e., makes an in-place right turn). Which of the following algorithms will successfully cause a robot to trace out a square-shaped path, with the robot ending up in its original position and facing in its original direction?

Step 1: MOVE_FORWARD () Step 2: ROTATE_LEFT () Step 3: MOVE_FORWARD () Step 4: ROTATE_LEFT () Step 5: MOVE_FORWARD () Step 6: ROTATE_LEFT () Step 7: MOVE_FORWARD () Step 8: ROTATE_LEFT ()

. 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 binary numbers. According to ASCII character encoding, which of the following letters is represented by the binary (base 2) number 1010100?

T

Sally notices that she has the same set of 10 blocks in her code in multiple places. She decides to create a new block (procedure) in Scratch so that she can simply replace those 10 blocks with one. Why would this be beneficial to Sally later when she debugs and reasons through her program? Select two answers.

The separate procedure will make the program more efficient, spending less time doing the same set of 10 blocks over and over again and If there's an error in the procedure, she can fix the error in the procedure without having to search through her code for each place the procedure is used

A city engineer is tasked with studying vehicular traffic patterns throughout a large metropolitan area. He designs a number of small, remote devices that can be installed along streets throughout the city to sense and record the hundreds of cars that pass through each of the city's five busiest intersections during a 24-hour period. Every time a car trips the sensor in a device, it increments an internal, 5-bit counter that stores the number of cars that have passed through the intersection since the counter was last reset. Every 24 hours, each device transmits the 5-bit value stored in its counter back to a central server that collects the daily data from all of the devices throughout the city. After transmitting, the counter in each device is reset back to 0. Fortunately, the engineer's supervisor points out a flaw in the device's design and orders that the engineer modify the design specifications for his device before building and installing all of the sensors. Which of the following is the most likely design flaw in this scenario?

The counter is not capable of counting hundreds of cars without exceeding the limit of the five bits of storage.

Which of the following is not true about digitizing physical media?

The digital version is equally as good as the physical one in terms of quality

Which of the following could be considered part of the beginning "state" of our Scratch program?

Visibility of sprites The background image A variable's value

As of 2016, the selling of used digital media is illegal. Along with selling it, there are many other illegal uses of digital media. Which of the following would be a legal use of digital media?

You download a song from iTunes and sync it to the cloud so that it is accessible on all of your devices

Which of the following code segments will display "Yes" if and only if your friend's name is Grace and her favorite food is either pizza or popcorn? Select 2 answers!

a. and c.

Consider the process of encoding and decoding a message using the following Caesar cipher encoding scheme in which the plaintext and ciphertext alphabets are offset by four positions, as shown below: Plaintext: a b c d e f g h i j k l m n o p q r s t u v w x y z Ciphertext: w x y z a b c d e f g h i j k l m n o p q r s t u v Which of the following encoded ciphertext strings decodes to an original plaintext message of "secret"?

oaynap

Which of the following would be the most appropriate name for a variable in a program?

time_remaining

Sam and Emma are creating a multiplayer tic-tac-toe game. Below is a segment of their code that is used so that the Sprite on screen can tell the user whose turn it is. Before each user's turn, this set of code is run. What would the condition need to be so that this part of the program runs correctly. The variable turn is initialized as 0 at the start and player 1 always goes first. Note: MOD is an operation that gives a number's remainder when it is divided by another number. Ex. 4 MOD 2 is zero, 5 MOD 2 is 1, 6 MOD 2 is zero, etc.

turn MOD 2 = 1

Consider the following code segment that appears in the middle of a program. Which of the following can replace the missing statement in the REPEAT UNTIL block so that the user will be required to enter the correct password of "swordfish" before they can continue with the rest of the program?

userPassword = "swordfish"

Consider the following procedure, validate, that is intended to display ÒPASSÓ if an integer, x, is within the range of 128 through 32768, inclusive. Values of x that are not within the range should display ÒFAILÓ. Which of the following sets of test cases would be the most sufficient for fully testing and verifying that the procedure correctly solves its intended function for all values of x?

validate(127) validate(128) validate(200) validate(32768) validate(32769)

Which condition will make the following code an infinite loop?

y = 1


Set pelajaran terkait

Chapter 15: Investments and International Operations

View Set

Новые слова 2-2 «Домашние проблемы»

View Set

N306 Nursing Management of Labor PREPU

View Set

N251 Exam One Prep U/ End of ChapterQuestions

View Set

Biology 116- Chapter 19 & 21: Learning Outcomes [Blood Vessels & Respiratory System]

View Set