ap csp semester 1

studied byStudied by 4 people
0.0(0)
Get a hint
Hint

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)

1 / 386

flashcard set

Earn XP

Description and Tags

387 Terms

1

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

New cards
2

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

New cards
3

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

d. x % 2 == 1

New cards
4

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

New cards
5

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

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

New cards
6

Which of the following has an error?

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

New cards
7

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' ])

New cards
8

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

New cards
9

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

New cards
10

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

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

New cards
11

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

New cards
12

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

c. Stops executing the function and returns the value

New cards
13

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

d. Ovals, Lines, Polygons

New cards
14

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

a. None

New cards
15

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

a. 100

New cards
16

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)

New cards
17

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

New cards
18

Which of the following functions successfully returns the number 10?

a. def my_function():return 10

New cards
19

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)

New cards
20

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

d. 5

New cards
21

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

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

New cards
22

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

c. 105

New cards
23

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

New cards
24

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

c. 105

New cards
25

Which shape is invisible on the canvas?

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

New cards
26

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

cow

New cards
27

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

d. h and bringUmbrella

New cards
28

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

d. 2

New cards
29

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

New cards
30

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.

New cards
31

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

1

New cards
32

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

New cards
33

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

New cards
34

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 }

New cards
35

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

b. 4

New cards
36

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

New cards
37

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

. def my_function():

New cards
38

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

New cards
39

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)

New cards
40

Which of the following lines of code has an error?

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

New cards
41

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

New cards
42

Which shape is not black at the top?

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

New cards
43

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

c. c.centerX *= 4

New cards
44

Do functions need to have parameters?

no

New cards
45

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

New cards
46

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

d. 'spanish'

New cards
47

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

New cards
48

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

c. reachedGoal

New cards
49

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

New cards
50

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

x

New cards
51

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

c. It makes the text thicker.

New cards
52

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

def my_function(number): return number*2

New cards
53

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

New cards
54

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')

New cards
55

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.

New cards
56

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.

New cards
57

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.

New cards
58

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

New cards
59

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

New cards
60

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

New cards
61

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

9

New cards
62

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

10100

New cards
63

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

11000000

New cards
64

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

256

New cards
65

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.

New cards
66

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.

New cards
67

Which of the following is true of intellectual property?

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

New cards
68

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

New cards
69

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.

New cards
70

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.

New cards
71

Computing device

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

New cards
72

Computing systems

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

New cards
73

Computing networks

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

New cards
74

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.

New cards
75

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

New cards
76

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

New cards
77

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

New cards
78

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

New cards
79

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

New cards
80

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

New cards
81

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

Tranmission Control Protocol

New cards
82

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

HTTP

New cards
83

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

New cards
84

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

New cards
85

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

New cards
86

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.

New cards
87

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

New cards
88

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

64

New cards
89

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

New cards
90

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

Lossy

New cards
91

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

New cards
92

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.

New cards
93

Copyright Example

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

New cards
94

Bit

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

New cards
95

Byte

8 bits

New cards
96

Overflow Error

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

New cards
97

Round-off Error

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

New cards
98

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.

New cards
99

Digital Data

Data that changes discreetly through a finite set of possible values

New cards
100

Sampling

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

New cards

Explore top notes

note Note
studied byStudied by 11 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 4 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 9 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 9921 people
Updated ... ago
4.6 Stars(25)
note Note
studied byStudied by 7 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 2 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 10 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 90 people
Updated ... ago
5.0 Stars(2)

Explore top flashcards

flashcards Flashcard45 terms
studied byStudied by 134 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard53 terms
studied byStudied by 1 person
Updated ... ago
5.0 Stars(1)
flashcards Flashcard334 terms
studied byStudied by 8 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard20 terms
studied byStudied by 5 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard30 terms
studied byStudied by 6 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard60 terms
studied byStudied by 58 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard37 terms
studied byStudied by 27 people
Updated ... ago
5.0 Stars(2)
flashcards Flashcard21 terms
studied byStudied by 50 people
Updated ... ago
5.0 Stars(3)