CSP final

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

Kobe is working on a basketball game and is experimenting with the variables he'll use for the game. His code looks like this: score ← 1 shots ← 0 DISPLAY (score) DISPLAY (shots) shots ← 3 score ← shots DISPLAY (shots) DISPLAY (score) What will be the output of that code?

1 0 3 3

Haruki is writing a program to share fun emoticons: DISPLAY ("Going for a walk:") DISPLAY ("ᕕ( ᐛ )ᕗ") The following paragraph describes how the program works. Fill in the blanks: This is a computer program with statements. Each statement calls a named DISPLAY which expects a single to determine what to display on the screen.

2,procedure, parameter

In the classic arcade game Donkey Kong, the code calculates the time allowed per level by multiplying the current level by 10 and adding 40. On level 22, that calculated time is 260. However, the game displays a time of 4 instead of 260. It is impossible for anyone to complete the level in just 4 seconds, so no player ever makes it past level 22. What is the most likely cause of the level 22 bug?

Integer overflow error

Which diagram best represents the relationship between the Internet and the World Wide Web?

Internet in world wide web

The following table compares two data transport protocols from the suite of protocols powering the Internet. Can it handle...Protocol 1Protocol 2...corrupt packets?YesYes...lost packets?NoYes...out of order packets?NoYes What are the most likely identities of Protocol 1 and Protocol 2?

Protocol 1 = UDP, Protocol 2 = TCP

Nora is learning to use image editing applications and doesn't understand when to lower the quality setting for JPEG saving. What's a good use case for using a lower quality setting?

Saving a thumbnail that will link to a full-sized version

Isabel is programming an app called Plantwatch, which lets users monitor the health of their plants. Which variables would she most likely use a string data type for?

species: The name of the plant species

A 2016 report found these statistics for citizens of Bolivia: Which of these would be the most effective way to reduce the digital divide between the urban and rural households?

A program that donates refurbished laptops to residents of rural villages.

What is true about the computing devices exchanging data over the Internet?

All the computing devices that are exchanging data over the Internet are following the rules of the Internet Protocol (IP)

A programmer uses this nested conditional in an online graphing calculator. IF (x < 0 AND y < 0) { quadrant ← "BL" } ELSE { IF (x < 0 AND y > 0) { quadrant ← "TL" } ELSE { IF (x > 0 AND y < 0) { quadrant ← "BR" } ELSE { IF (x > 0 AND y > 0) { quadrant ← "TR" } } } } When x is 52 and y is -23, what will be the value of quadrant?

BR

The following code segment stores and updates a list of cities to visit: topCities ← ["Kyoto", "Florianopolis", "Wellington", "Puerto Viejo", "Sevilla"] topCities[2] ← "Ankara" topCities[4] ← "Taipei" After running that code, what does the topCities list store?

"Kyoto", "Ankara", "Wellington", "Taipei", "Sevilla"

When writing binary data, we often put a space between each byte to make it easier for humans to read. Consider this binary data: 1011011010110001 Which option puts a space after each byte?

1011011010110001

Startuppr is a web company that's running their servers out of their garage. Their network administrator is tasked with determining if there is a single point of failure in the network—a router whose outage could cause their servers to lose connection to the Internet. The administrator analyzes this partial diagram of the network: Each circle is a router, each line is a connection, and the lines with arrows indicate connections to further routers on the Internet. How many single points of failure would the network administrator find?

2

Tyrone is creating a text-based card game. He starts off with this code that deals 3 cards: DISPLAY ("Ace of clubs\n") DISPLAY (" ___ \n") DISPLAY ("|A |\n") DISPLAY ("| O |\n") DISPLAY ("|OxO|\n") DISPLAY ("7 of diamonds\n") DISPLAY (" ___ \n") DISPLAY ("|7 |\n") DISPLAY ("| /\|\n") DISPLAY ("|_\/|\n") DISPLAY ("5 of clubs\n") DISPLAY (" ___ \n") DISPLAY ("|5 |\n") DISPLAY ("| O |\n") DISPLAY ("|OxO|\n") After writing that code, Tyrone decides to use a different way to draw the bottom line of the clubs cards: DISPLAY ("|O,O|\n") Part 1: How many lines will Tyrone need to update in his code? Now imagine that Tyrone had originally defined a procedure to draw the club cards, like so: PROCEDURE drawClubs () { DISPLAY ("| O |\n") DISPLAY ("|OxO|\n") } DISPLAY ("Ace of clubs\n") DISPLAY (" ___ \n") DISPLAY ("|A |\n") drawClubs () DISPLAY ("7 of diamonds\n") DISPLAY (" ___ \n") DISPLAY ("|7 |\n") DISPLAY ("| /\\|\n") DISPLAY ("|_\\/|\n") DISPLAY ("5 of clubs\n") DISPLAY (" ___ \n") DISPLAY ("|5 |\n") drawClubs () Part 2: Given this starting code, if Tyrone decides on a new way to draw the bottom line of the clubs, how many lines will he need to update? Part 3: Which of these is not a drawback of Tyrone having to update code in multiple places?

2,1, If he has to update multiple places in the code, the program will run much slower.

Dixie is planning a water balloon fight for her birthday party and writing a program to help calculate how many bags of balloons they'll need to buy. The procedure calcBalloonBags returns the number of bags needed for a given number of players, number of rounds, and number of balloons in the bag. PROCEDURE calcBalloonBags(numPlayers, numRounds, balloonsInBag) { numTeams ← FLOOR(numPlayers / 2) numBalloons ← numTeams * numRounds RETURN CEILING(numBalloons / balloonsInBag) } This procedure relies on two built-in procedures, FLOOR for rounding a number down and CEILING for rounding a number up, which avoids the issue of partial teams and partial bags. Dixie then runs this line of code: bagsNeeded ← calcBalloonBags(30, 10, 50) What value is stored in bagsNeeded?

3

You decide to design a clock that shows all the numbers in binary. What's the least number of bits that you'll need to represent the current minute (0-59) in binary?

6

How many values can a binary digit store?

A binary digit can store one of two values (0 or 1).

This program prompts a user to enter a secret code. Once they type the right code, it lets them continue. But if they make more than 3 bad attempts, it doesn't let them keep guessing. 1: badAttempts ← 0 2: codeCorrect ← false 3: secretCode ← "banana" 4: REPEAT UNTIL (codeCorrect = true OR badAttempts > 3) 5: { 6: DISPLAY("Enter the secret code") 7: guessedCode ← INPUT() 8: IF (guessedCode = secretCode) 9: { 10: DISPLAY("You're in!") 11: } 12: ELSE 13: { 14: DISPLAY("Beeeep! Try again!") 15: } 16: } This code is incorrect, however: the loop in the code never stops repeating. Where would you add code so that the loop ends when expected?

Between line 10 and 11 Between line 14 and 15

The two procedures below are both intended to return the total number of excess calories eaten in a day based on a list of calories in each meal. Procedure 1: PROCEDURE calcExcess1(meals) { totalCalories ← 0 FOR EACH meal IN meals { totalCalories ← totalCalories + meal } excessCalories ← totalCalories - 2000 RETURN excessCalories } Procedure 2: PROCEDURE calcExcess2(meals) { totalCalories ← 0 FOR EACH meal IN meals { totalCalories ← totalCalories + meal excessCalories ← totalCalories - 2000 } RETURN excessCalories } Consider these procedure calls: excess1 ← calcExcess1([700, 800, 600, 300]) excess2 ← calcExcess2([700, 800, 600, 300]) Which of these statements best describes the difference between the procedure calls?

Both procedure calls return the same value, but the second procedure requires more computations.

Barry is making a program to process user birthdays. The program uses the following procedure for string slicing: NameDescriptionSUBSTRING (string, startPos, numChars)Returns a substring of string starting at startPos of length numChars. The first character in the string is at position 1. His program starts with this line of code: userBday ← "03/31/84" Which of these lines of code displays the day of the month ("31")?

DISPLAY (SUBSTRING (userBday, 4, 2))

Eliott is working with a game designer on a video game. The designer sends them this flow chart: Flow chart that starts with diamond and branches into two rectangles. * Diamond contains question, "Are experience points greater than 100?" * Arrow marked "true" leads to rectangle with text "Add 10 to the level". * Arrow marked "false" leads to rectangle with text "Add 1 to the level". [How do you read a flowchart?] He must implement that logic in code, using the variables experiencePoints and level. Which of these code snippets correctly implements the logic in that flow chart?

IF (experiencePoints > 1000) { level ← level + 10 } ELSE { level ← level + 1 }

Each IP packet contains a destination address. What is the primary purpose of the destination address?

It helps the router know where to send the packet.

In what situations is the Internet Protocol (IP) used?

It is used every time that two computing devices send data to each other over the Internet.

A startup is developing a new web browser with a focus on accessibility for visually impaired users. The startup founder is considering the benefits and drawbacks of releasing the code online under an open source license. What would be a consequence of releasing the code with an open source license?

Other companies and individuals would be able to view and use the code according to the conditions of the open source license.

What is true about the process of converting analog data into digital data?

Regardless of the sampling interval used, the digital version can never contain as much detail as the original analog data.

A new high school is built and needs to be connected to the Internet. The IT administrator found these four local providers for Internet services: ProviderBandwidthBeyondNet100100100 MbpsSpectralWeb505050 MbpsFinalLink100010001000 MbpsTopSat252525 Mbps Which of these comparisons between the providers is correct?

SpectralWeb can transfer 222 times more data per second than TopSat.

Consider this sequence of bits: 010101010011001101001011 000001011000000100111100 011001011000001010010111 010111110001000111100111 010110110010011010111000 What is true about this binary data?

This sequence of bits might represent a number, an English word, or a Chinese word.

A startup creates a website called SpeakerMeter which is designed for use at conferences. SpeakerMeter enables conference attendees to continuously rate speakers as they are speaking, so that speakers can see how much attendees like the different parts of their talks. Which of these situations would reveal the most about SpeakerMeter's scalability?

Using it for a conference with 10,000 attendees

Amelie is planning a gingerbread house making workshop for the neighborhood, and is writing a program to plan the supplies. She's buying enough supplies for 15 houses, with each house being made out of 5 graham crackers. Her favorite graham cracker brand has 20 crackers per box. Her initial code: numHouses ← 15 crackersPerHouse ← 5 crackersPerBox ← 20 neededCrackers ← crackersPerHouse * numHouses Amelie realizes she'll need to buy more crackers than necessary, since the crackers come in boxes of 20. Now she wants to calculate how many graham crackers will be leftover in the final box, as she wants to see how many extras there will be for people that break their crackers (or get hungry and eat them). Which line of code successfully calculates and stores the number of leftover crackers in the final box?

extras ← crackersPerBox - (neededCrackers MOD crackersPerBox)

A gardener is writing a program to detect whether the soils for their citrus trees are the optimal level of acidity. IF (measuredPH > 6.5) { soilState ← "high" } ELSE { IF (measuredPH < 5.5) { soilState ← "low" } ELSE { soilState ← "optimal" } } Which of these tables shows the expected values of soilState for the given values of measuredPH?

high high op op

The following procedure calculates the slope of a line and takes 4 numeric parameters: the x coordinate of the first point, the y coordinate of the first point, the x coordinate of the second point, and the y coordinate of the second point. PROCEDURE lineSlope (x1, y1, x2, y2) { result ← (y2 - y1) / (x2 - x1) DISPLAY (result) } This graph contains a line with unknown slope, going through the points [1, 3][1,3]open bracket, 1, comma, 3, close bracket and [5, 2][5,2]open bracket, 5, comma, 2, close bracket: \small{1}1\small{2}2\small{3}3\small{4}4\small{5}5\small{1}1\small{2}2\small{3}3\small{4}4yyxx Graph with line going through 2 marked points [1, 3] and [5, 2]. Which of these lines of code correctly calls the procedure to calculate the slope of this line?

lineSlope(1, 3, 5, 2)

Byte pair encoding is a compression algorithm that replaces repeated pairs of characters in a string with a character that isn't in the data, and creates a table of replacement mappings. Here's a quote from Dr. Seuss: "Think left and think right and think low and think high. Oh, the thinks you can think up if only you try!" Which of the following character pairs would the algorithm replace?

th &in


Conjuntos de estudio relacionados

MGT 471: Chp 1 reading, What makes Entrepreneurs Entrepreneurial? Sarasvathy

View Set

Legal Environment of Business Exam 4 Mindtap (Ch. 32, 33, 34, 35)

View Set

Infláció. Infláció és a munkanélküliség kapcsolata

View Set

Investment Planning: Formula Investing & Investment Strategies (Module 10)

View Set

Science Bowl sample questions set 1

View Set