all the ap csp

Ace your homework & exams now with Quizwiz!

How do computers represent complex information?

-Computing devices use patterns of bits to represent complex information. -Depending on context the same sequence of bits may represent different types of information -Common abstractions that are represented by computing devices include numbers, characters, and color.

What is the centerX of c after we press the mouse once, according to the code below? g = Group(Star(200, 200, 10, 10)) c = Circle(100, 100, 5, fill='red') g.add(c) def onMousePress(mouseX, mouseY): g.centerX += 10 c.centerX += 5

. 115

Which shape is not black at the top?

. Rect(50, 50, 100, 100, fill=gradient('black', 'yellow'))

Which of the following is the correct way to create a function in Python?

. def my_function():

How many return values come out of the function sum?def sum(first, second): result = first + second return result

1

Convert the decimal (base-10) number 20 to binary (base-2).

10100

What is the centerX of c after we press the mouse once, according to the code below? g = Group(Star(200, 200, 10, 10)) c = Circle(100, 100, 5, fill='red') def onMousePress(mouseX, mouseY):g.centerX += 10 c.centerX += 5

105

What is the centerX of c after we run the code below? g = Group(Star(200, 200, 10, 10)) c = Circle(100, 100, 5, fill='red') for shape in g.children: c.centerX += 5

105

Which of the following binary (base-2) numbers is LARGEST?

11000000

What is the output of the following program?def sum_to(num): sum = 0 for i in range(num+1): sum += i print(sum)x = 5sum_to(x)print(x)

15 5

Your computer uses 4 bits to represent decimal numbers (0, 1, 2, 3 and so on) in binary. What is the SMALLEST decimal number for which an overflow error would occur?

16

How many total numbers can be represented with an 8-bit binary (base-2) system?

256

What is the smallest number that will cause an overflow error if a computer uses 6 bits?

64

Byte

8 bits

A car dealership assigns each parking spot on the lot a unique ID using binary digits. What is the minimum number of bits needed if there are 300 spots?

9

Convert the binary (base-2) number 1001 to decimal (base-10).

9

Which of the following best describes how computing devices represent information?

A computer represents data as bits which is either a 0 or a 1.

Bit

A contraction of "Binary Digit"; the single unit of information in a computer, typically represented as a 0 or 1

Computing systems

A group of computers working together to serve a common purpose.

Computing networks

A group of interconnected computers that can send or receive data.

Computing device

A machine that can run a program, including computers, tablets, servers, routers, and smart sensors

Copyright Example

A musician incorporates parts of Wutangs music into his song after he gets permission from Wutang.

Creative Commons Example

A musician wants his songs to be downloaded for free. He doesn't mind if his songs are modified or incorporated into other songs.

Sampling

A process for creating a digital representation of analog data by measuring the analog data at regular intervals called samples.

Lossy Compression

A process for reducing the number of bits needed to represent something in which some information is lost or thrown away. This process is not reversible.

Path

A sequence of direct connections; the series of connections between computing devices on a network starting with a sender and ending with a receiver.

Bob purchases a smartphone and is immediately able to use it to send a photo over the Internet to friend who lives in a different country. Which of the following is NOT necessary to make this possible?

A singe direct connection is established between any two devices connected to the Internet

Which of the following situations is most likely to cause issues arising from the digital divide?

A state makes voter registration forms available only by visiting a government website

Which of the following is NOT true of how computers represent complex information?

Abstraction helps represent complex information by surfacing complexity that might otherwise be hidden.

Open access Example

Allows software to be written that scans through a database of scientific journals and then create a list of all the articles written about Covid

Arman takes a picture with his smartphone which he subsequently posts online. Beatrice finds the picture online and posts a copy of it on her website with an attached Creative Commons license. Which of the following best describes who owns the photo?

Arman owns the photo because he was the original creator and did not license the work.

Which of the following is true of intellectual property?

Creative Commons enables content creators to freely distribute their otherwise copyrighted work.

Digital Data

Data that changes discreetly through a finite set of possible values

Analog Data

Data with values that change continuously, or smoothly, over time. Some examples of analog data include music, colors of a painting, or position of a sprinter during a race.

Overflow Error

Error from attempting to represent a number that is too large.

Round-off Error

Error from attempting to represent a number that is too precise. The value is rounded.

Which of the following Internet protocols is used to request and send pages and files on the World Wide Web?

HTTP

What will be drawn when we call f(x)? def g(): Label('Hi! ', 120, 200, size=24) def f(x): g() Label("I'm happy", 200, 200, size=24)

Hi!I'm happy

Which of the following best describes the purpose of an IP address?

IP addresses provide a unique number for identifying devices that send and receive information on the Internet

Which of the following lines of code has an error?

Line(10, 10, 100, lineWidth=101)

Which type of compression is used when you want to compress a file but don't want to maintain the original quality?

Lossy

Which of the following is true of lossy and lossless compression algorithms?

Lossy compression algorithms are typically better than lossless compression algorithms at reducing the number of bits needed to represent a piece of data.

Ryan is designing an app that needs to quickly send low quality photos between users. Most smartphones take much higher quality photos than Ryan needs for his app. Which answer best describes the type of compression Ryan should choose and why?

Lossy compression since it typically results in smaller data sizes.

Which of the following is true of how packets are sent through the Internet?

Packet metadata is used to route and reassemble information traveling through the Internet

Which of the following is MOST likely to be an outcome of the digital divide?

People from some racial or ethnic groups have unequal access to computing technology.

An Internet Service Provider (ISP) is a company that builds the routers and wired connections that allow individuals to access the Internet. Why would an ISP consider adding additional redundant connections to its network? Choose the BEST answer.

Redundant networks are more reliable

Jorge is sending a large image file to a friend as part of a shared classroom project. Which of the following is most likely true if Jorge opts to compress the image before sending it?

The image will require fewer bits in order to be represented.

Victor is watching an online video. The video is being sent to his laptop by a server over the Internet which splits the video into packets and sends them in the order they appear in the video. Which of the following is true about how the packets will arrive at his computer?

The packets may arrive out of order

When visiting a museum Lian takes a photo of a painting with a smartphone which stores the photo as an image file. Which of the following is true?

The photo is a digital representation of the analog painting

Which of the following best describes the protocols used on the Internet?

The protocols of the Internet are open and used by all devices connected to the network

Which of the following is true of how the Internet has responded to the increasing number of devices now using the network?

The protocols of the Internet were designed to scale as new devices are added

Which of the following Internet protocols is MOST important in reassembling packets and requesting missing packets to form complete messages?

Tranmission Control Protocol

Which of the following is true of how computers represent numbers?

Using a fixed but large number of bits can eliminate the possibility of round off error when representing numbers in binary

Lucy is completing a project as part of a science class using materials she found online. Which of the following is MOST LIKELY to lead to legal consequences?

Using images posted online by another student without permission or citation

Lossless Compression

a data compression algorithm that allows the original data to be perfectly reconstructed from the compressed data. -A process for reducing the number of bits needed to represent something without losing any information. This process is reversible.

What will app.index be if we run the following code and click the mouse 10 times? app.index = 0 app.list = [ 1, 2, 3 ] def onMousePress(x, y): app.index = (app.index + 1) % len(app.list)

a. 1

g = Group(Star(200, 200, 10, 10)) c = Circle(100, 100, 5, fill='red') for shape in g.children: shape.centerX += 5

a. 100

Consider the following code snippet:WIDTH = 300HEIGHT = 300def draw_circle(radius, color, x, y): circle = Circle(radius) circle.set_color(color) circle.set_position(x, y) add(circle)draw_circle(40, "red" 100, 300)draw_circle(50, "green", 50, 100)draw_circle(70, "blue", WIDTH/2, HEIGHT/2)draw_circle(25, "yellow", WIDTH/2, 300)In the third call to draw_circle(), what values are passed to the coordinates of the center of the circle?

a. 150, 150

What gets printed after the code below is run? languages = [ 'python', 'spanish', 'english' ] language = languages.remove('english') print(language)

a. None

Which of the following has an error?

a. Rect(30, 30, 100, 200, fill=none)

Which of the following functions successfully returns the number 10?

a. def my_function():return 10

If we want to draw a circle using our helpful draw_circle function at position (300, 400) with a radius of 40 and color blue, which is the correct function call?As a reminder, here's the function header for draw_circle:def draw_circle(radius, color, x, y)

a. draw_circle(40, Color.blue, 300, 400)

Which of the following is true about if-elif-else statements?

a. After using if, an elif can be added as an additional test.

In the following function print_three_times:def print_three_times(word): print(word) print(word) print(word)What is the parameter of the function?

a. word

What is the value of s in the code below? myList = [ 1, 2, 3 ] s = myList[0] + myList[2]

b. 4

Why do we write functions? a. Make our code reusable Selected:b. All of these This answer is correct. c. Make our code easier to understand by giving a readable name to a group of instructions d. Avoid writing repeated code

b. All of these

Which shape is invisible on the canvas?

b. Rect(50, 50, 100, 100, fill=None)

Which of the following are the parameter(s) of the function greet shown below? def greet(labelSize, color): Label('Hi', 100, 100, fill=color, size=labelSize)

b. color and labelSize

If added to the program below, which of the following additional functions would not cause an error?x = 10def add_nums(): y = 2 z = x + y print z

b. def subtract_nums():y = 5z = x - yprint z

Suppose we have a shape player with the custom property player.hunger and a custom method player.die(). We want the player to die if their hunger reaches 0. Which of the following code segments properly write this code? I. PROCEDURE onMousePress(mouseX, mouseY) { player.hunger ← player.hunger - 1 IF(player.hunger = 0) { player.die() } } II. PROCEDURE onMousePress(mouseX, mouseY) { IF(player.hunger ≠ 0) { player.hunger ← player.hunger - 1 } ELSE { player.die() } } III. PROCEDURE onMousePress(mouseX, mouseY) { player.hunger ← player.hunger - 1 IF(player.hunger > 0) { player.die() } }

b. I and II

What is printed by the following code?def print_numbers(first, second, third): print(first) print(second) print(third)middle = 5print_numbers(4, middle, 6)

c. 4 5 6

How many times will the print statement be called in the code below? for i in range(3): for j in range(3): print(i, j)

c. 9

How does a label change if you set 'bold=True'?

c. It makes the text thicker.

What is the purpose of a return statement in a function?

c. Stops executing the function and returns the value

What is the value of languages after the code below is run? languages = [ 'python', 'spanish', 'english' ] languages.append('french')

c. [ 'python', 'spanish', 'english', 'french' ]

Which of the following correctly multiplies the centerX of a circle called c by 4?

c. c.centerX *= 4

Which of the following is the correct way to bring a circle named c to the front of the canvas? a. front(c) b. toFront(c) Selected:c. c.toFront() This answer is correct. d. c.toFront

c. c.toFront()

Consider the drawKabob procedure: PROCEDURE drawKabob(flavors) { Line(30, y, 400, y, fill='cornSilk', lineWidth=20) index ← 1 REPEAT LEN(flavors) TIMES { centerX ← 75 + index * 50 IF(flavors[index] = 'meat') { Circle(centerX, 200, 25, fill='sienna') } IF(flavors[index] = 'veggie') { Line(centerX, 175, centerX, 225, fill='green', lineWidth=35) Line(centerX, 175, centerX, 225, fill='red', lineWidth=20) Line(centerX, 175, centerX, 225, fill='white', lineWidth=5) } index ← index + 1 } } Which answer provides the proper procedure arguments to draw the image below? [1 point]

c. drawKabob([ 'veggie', 'meat', 'meat', 'veggie', 25, 'veggie' ])

Consider the code snippet:def draw_circle(radius, color, x, y): circle = Circle(radius) circle.set_color(color) circle.set_position(x, y) add(circle)What is the return value for this function?

c. this function has no return value

Which of the functions is called when ticketsBought = 12? if (ticketsBought < 12): cancelShow() elif (ticketsBought == 12): reachedGoal() else: soldOutShow('yellow')

c. reachedGoal

What is the value of favoriteAnimal after the code below is run? animals = [ 'dog', 'cat', 'cow', 'pig' ] favoriteAnimal = animals[2]

cow

Your teacher wants to write a program to add 5 points to everyone's grades, which are stored in the list app.grades. But your teacher doesn't know how to code so they've enlisted your help in exchange for giving you an extra 2 points (7 total)! You know your grade is the last one in the list. Which of the following code segments will solve this problem for your teacher?

d. index ← 1 REPEAT LEN(app.grades) TIMES { app.grades[index] ← app.grades[index] + 5 IF(index = LEN(app.grades)) { app.grades[index] ← app.grades[index] + 2 } index ← index + 1 }

What gets printed after the code below is run? languages = [ 'python', 'spanish', 'english' ] language = languages.pop(1) print(language)

d. 'spanish'

How many parameters go into the function sum?def sum(first, second): result = first + second return result

d. 2

Which of the following will NOT be printed? for i in range(2, 5): print(i)

d. 5

Which of the following is not a valid property for Labels? a. border b. italic c. font Selected:d. All of these are valid properties for Labels.

d. All of these are valid properties for Labels.

What shapes are drawn in the following pumpkin? (Don't include the background!)

d. Ovals, Lines, Polygons

The following code has a logical error. The program should draw two circles centered where the mouse is released, if the mouse is in the bottom half of the canvas. Which answer choice contains the code to fix the error? PROCEDURE onMouseRelease(x, y) { IF(mouseY > 200) { Circle(mouseX, mouseY, 60, fill='blue') Circle(mouseX, mouseY, 30, fill='green') } }

d. Replace the function definition with:PROCEDURE onMouseRelease(mouseX, mouseY)

Which function gets called if we call h(False)? def h(isSunny): if (isSunny == True): wearHat() else: bringUmbrella()

d. h and bringUmbrella

Which of the following correctly creates a list of the numbers 1, 2, 3, 4, and 5?

d. numbers = [1, 2, 3, 4, 5]

What does the mystery function do in the code snippet below?def mystery(x, y): if x < y: return x else: return ya = mystery(10, 14)b = mystery(82, 28)print(a)print(b)

d. returns the smaller of two values passed to it

Which of the following will return True if x is odd?

d. x % 2 == 1

Which of the following functions successfully returns double the variable 'number'?

def my_function(number): return number*2

Question 8 The following code defines the drawShapes() procedure that draws shapes depending on what the arguments are: PROCEDURE drawShapes(lotsOfShapes, x) { IF(lotsOfShapes = true) { Circle(200, 200, 50, fill='blue') Rectangle(x, 200, 100, 100, fill='green') } ELSE { Circle(200, 200, 50, fill='red') } IF(x ≥ 150) { Rectangle(200, 200, 100, 100, fill='green') } } What should the procedure call look like in order to draw both a red circle and a green rectangle (and nothing else)?

drawShapes(false, 150)

Two devices are connected to the Internet and communicating with one another. A gardener digging a large hole accidentally breaks the wires in the network that is currently being used by the devices to communicate. The network begins using a different path on the network and communication continues as normal. This situation best exemplifies which principle?

fault-tolerance

Which of the following would be a legal function call for the given code below? def greet(labelSize, color): Label('Hi', 100, 100, fill=color, size=labelSize) a greet('white', 40) b greet(20, 'blue') c greet('yellow', 'pink') d greet(20, 60)

greet(20, 'blue')

Do functions need to have parameters?

no

The Internet is built on a stack of communication protocols that are ______. As a result, any computer can communicate with other computers on the Internet, without need to apply for a license from a company.

nonproprietary

Question 4 Which shapes remains visible in the group after we press and release the mouse? g = Group() r = Rect(10, 10, 200, 200, fill='blue') s = Star(200, 200, 30, 5, fill='purple') c = Circle(100, 100, 5, fill='red') o = Oval(100, 100, 20, 20, fill='green') g.add(r) g.add(s) g.add(c) g.add(o) def onMousePress(x, y): g.remove(r) o.visible = False def onMouseRelease(x, y): g.add(r) g.remove(c)

r s

def quadruple_number(x): quad_x = 4 * x print(quad_x)What is the parameter of the function quadruple_number?

x


Related study sets

Organizational Communication Exam Two

View Set

Chapter 14: Stress, Lifestyle, and Health

View Set

Health Services Practice Management... Quizzes

View Set

Chapter 9: Physical and cognitive Development in Adoslence

View Set

California: Real Estate Principles - Chapter 22

View Set

Workplace - Corporate Social Responsibility

View Set