CS1

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

c

How many times is f(x) called when we call h(5, 'blue')?def h(x, color): if (x == 5): f(x) if (color == 'blue'): f(x) else: f(x) [1 point] a. 0 b. 1 c. 2 d. 3

D

If the mouse is moved without pressing, what is drawn according to the code below?def onMouseDrag(mouseX, mouseY): Circle(mouseX, mouseY, 20, fill='orange') def onMousePress(mouseX, mouseY): Rect(mouseX, mouseY, 20, 20, fill='brown') [1 point]a. Brown rectangles b. Orange circles c. Both brown rectangles and orange circles d. Nothing

D

If the mouse is pressed and dragged, what is drawn according to the code below?def onMouseMove(mouseX, mouseY): Star(mouseX, mouseY, 20, 5, fill='red') def onMouseRelease(mouseX, mouseY): Circle(mouseX, mouseY, 15, fill='yellow')-a. Red stars-b. Yellow circles-c. Both red stars and yellow circles-d. Nothing

B

What will be printed if we press the mouse, given the following code?r = Rect(0, 0, 400, 400, fill='orange') o = Oval(200, 200, 20, 10, fill='yellow') def onMousePress(x, y): if (o.containsShape(r) == True): print('o contains r') elif (r.containsShape(o) == True): print('r contains o') else: print('no containing')[1 point] a. 'o contains r' b. 'r contains o' c. 'no containing' d. There will be an error.

D

Which code draws a polygon with 5 sides? [1 point] a. RegularPolygon(100, 100, 5, 30) b. RegularPolygon(100, 5, 100, 30) c. Polygon(100, 100, 200, 150, 300, 150) d. RegularPolygon(100, 100, 30, 5)

b. Polygon(10, 10, 100, 150, 350, 300, fill='grey')

Which code draws this a Polygon? [1 point] a. Rect(10, 20, 150, 150, fill='grey') b. Polygon(10, 10, 100, 150, 350, 300, fill='grey') c. Polygon(150, 400, 250, 300, 100, 300, fill=None, border='grey') d. RegularPolygon(100, 100, 130, 3, fill='grey

B

Which of following correctly multiplies and updates the value of a label 'x' by 4? [1 point] a. x.value = 4 b. x.value *= 4 c. x.value * 4 d. x.value =* 4

D

Which of the following are the parameter(s) of the function sayHello above? [1 point] a. color b. labelSize c. sayHello has arguments, not parameters d. color and labelSize

a

Which of the following correctly defines a global variable? [1 point] a. r = Rect(100, 100, 200, 200, fill='blue') b. Circle = Circle(200, 200, 50, fill='red') c. def = Star(200, 200, 20, 10) d. Oval(200, 200, 30, 30)

c

Which of the following correctly identifies when onMouseDrag is called? [1 point] a. When the mouse is pressed. b. When the mouse is moved but not held. c. When the mouse is moved and held. d. When the mouse is not moving.

B

Which of the following correctly identifies when onMouseMove is called? [1 point] a. When the mouse is pressed. b. When the mouse is moved but not held. c. When the mouse is held and moved at the same time. d. Whenever the mouse is moving.

B

Which of the following correctly increases the radius of a star called 's' by 10? [1 point] a. s.radius = 10 b. s.radius += 10 c. s.radius =+ 10 d. s.radius + 10

C

Which of the following corresponds to the s.centerY and s.points?s = Star(200, 200, 40, 6, fill='pink') [1 point] a. s.centerY = 200, s.points = 40 b. s.centerY = 40, s.points = 6 c. s.centerY = 200, s.points = 6 d. s.centerY = 6, s.points = 200

D

Which of the following functions is/are called if the mouse is being held and moved across the canvas?def onMouseDrag(mouseX,mouseY):drawBigCircle(mouseX, mouseYDefonMouseMove(mouseX,mouseY)drawSmallCircle(mouseX, mouseY) a. onMouseMove and drawBigCircle-b.onnMouseDrag and drawSmallCircle-c. onMouseMove and drawSmallCircle-d. onMouseDrag and drawBigCircle

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

Which of the following has an error? [1 point] a. Circle(100, 100, 50, border='gold') b. Line(10, 10, 100, 200, lineWidth=30) c. Star(200, 200, 50, 5, roundness=30) d. Rect(30, 30, 100, 200, fill=none)

A

Which of the following incorrectly defines a global variable according to our syntax guidelines? [1 point] a. Rect = Rect(100, 100, 200, 200, fill='blue') b. C = Circle(200, 200, 50, fill='red') c. s = Star(200, 200, 20, 10) d. square = Rect(200, 200, 30, 30)

B

Which of the following is a legal name for a variable? [1 point] a. def b. redLabel c. 5hello d. say hi

C

Which of the following is a valid call to the function g and will have f(x) be called 3 times?def g(x, y): if (x < 5): f(x) if (y < 10): f(x) f(x) [1 point] a. g(5, 10) b. g(10, 5) c. g(4, 5) d. g(4, 10)

c

Which of the following is a valid custom property for a shape? [1 point] a. fill b. opacity c. count d. width

a

Which of the following is an invalid use of a shape property given a shape 'r'? [1 point] a. r.align = 'bottom' b. r.fill = 'green' c. r.opacity = 50 d. r.dashes = True

D

Which of the following is drawn when the mouse is released?def onMouseRelease(x,y): Circle(x, y, 15, fill='blue') Star(x, y, 10, 5, fill='green') [1 point] a. A green circle with a blue star on top b. A green star with a blue circle on top c. A blue star with a green circle on top d. A blue circle with a green star on top

A

Which of the following is drawn when we press the 'a' key and then release it?def onKeyPress(key): RegularPolygon(200, 200, 20, 5, fill='blue') def onKeyRelease(key): if (key == 'b'): Rect(100, 200, 50, 50, fill='magenta') [1 point]-a. A blue 5 sided polygon is drawn.-b. A magenta rectangle is drawn.-c. A blue 5 sided polygon and a magenta rectangle are drawn.-d. Nothing is drawn.

a

Which of the following is drawn when we press the 'h' key and then release it?def onKeyPress(key): if (key == 'h'): Circle(200, 200, 20, fill='green') def onKeyRelease(key): Star(100, 200, 30, 7, fill='red') [1 point]-a. A green circle and red star are drawn.-b. A green circle is drawn.-c. A red star is drawn.-d. Nothing is drawn.

D

Which of the following is false about if-elif-else statements? [1 point] a. elif is short for else if. b. elif can be used without an else statement. c. After using if, an elif can be added as an additional test. d. The bodies of multiple elif's can run.

A

Which of the following is false about naming functions and parameters? a. Names can have spaces. b. Names can have digits. c. Some names are reserved by python. d. Names cannot start with digits.

d

Which of the following is not a parameter of the function drawPrettyStar? [1 point] a. numberOfPoints b. radius c. color d. fill

B

Which of the following is not a shape method? [1 point] a. containsShape b. hitPoint c. toBack d. hitsShape

D

Which of the following is not a valid custom property for a shape? [1 point] a. centerX b. height c. left d. All of the above.

d

Which of the following is the correct way to bring a circle named c to the front of the canvas? [1 point] a. toFront(c) b. front(c) c. c.toFront d. c.toFront()

A

Which of the following is the correct way to push a star named s to the back of the canvas? [1 point] a. s.toBack() b. toBack(s) c. back(s) d. s.toBack

Solid black with grey border to the bottom right

Which of the following is the result of the following code? (Ignoring the letter label) Rect(50, 50, 200, 200) Rect(150, 150, 200, 200, fill=None, border='grey', borderWidth=10)

B

Which of the following results in a call to onKeyRelease? [1 point] a. Pressing the 's' key. b. Releasing the 's' key. c. Calling onKeyPress('s') in a test case. d. None of the above.

A

be printed if we click the mouse with the following code.?c = Circle(200, 200, 30, fill='sienna') s = Star(200, 200, 20, 10, fill='lavender') def onMousePress(x, y): if (c.containsShape(s) == True): print('c contains s') elif (s.containsShape(c) == True): print('s contains c') else: print('no containing')[1 point]-a. 'c contains s'-b. 's contains c'-c. Both 'c contains s' and 's contains c'-d. There will be an error.

C

blue circle being drawn when the mouse is dragged in the bottom quarter of the canvas and a purple circle being drawn otherwise?def drawCircle(color): Circle(200, 200, 100, fill=color) def onMouseDrag(mouseX, mouseY): # insert if statement here drawCircle('blue') else: drawCircle('purple') -a. if (mouseY >= 100):-b. if (mouseX >= 300):-c. if (mouseY >= 300):-d. if (mouseX >= 100):

B

code draw if the function is called and the condition is false?def onMouseDrag(mouseX, mouseY): if (mouseX != 200): Star(mouseX, mouseY, 10, 5, fill='purple') Star(mouseX, mouseY, 5, 5)-a. It will draw a purple star, and nothing else.-b. It will draw a black star, and nothing else.-c. It will draw a purple star with a black star on top.-d. It will draw nothing.

c

drawn by the code below when the mouse is clicked on the canvas?def onMousePress(mouseX, mouseY): Rect(100, 200, 150, 150, fill='blue', border='yellow')-a. A blue rectangle with no border-b. A yellow rectangle with blue border-c. A blue square with yellow border-d. A transparent square with yellow border

d

drawn when the mouse is released?def onMouseRelease(mouseX, mouseY): Rect(mouseX, mouseY, 30, 50, fill='blue') Rect(mouseX + 10, mouseY - 10, 30, 50, fill='green') -a. A blue rectangle covering part of a green rectangle-b. Two non-touching rectangles-c. A green rectangle-d. Two overlapping rectangles of different colors

D

following calls to onMousePress will draw nothing?def onMousePress(mouseX, mouseY): if (mouseX != mouseY): Circle(mouseX, mouseY, 10, fill='mediumVioletRed') -a. onMousePress(100, 200)-b. onMousePress(100, 400)-c. onMousePress(200, 100)-d. onMousePress(300, 300)

A

following code draw if the condition is true?def onMouseMove(mouseX, mouseY): if (mouseY <= 200): RegularPolygon(mouseX, mouseY, 10, 8) else: RegularPolygon(mouseX, mouseY, 10, 5) [1 point]-a. An 8-sided regular polygon-b. A 5-sided regular polygon-c. An 8-sided regular polygon and a 5-sided regular polygon-d. Nothing

C

following is drawn when the mouse is moved and not pressed on the bottom half of the canvas?def onMouseMove(mouseX, mouseY): if (mouseY < 200): RegularPolygon(mouseX, mouseY, 35, 5, fill='blue') else: Rect(mouseX, mouseY, 50, 50, fill='green')-a. Both blue pentagons of radius 35 and green rectangles-b. Nothing-c. Green rectangles-d. Blue pentagons of radius 35

d

. What will be drawn when we call f()?def g(): Label('Hi! ', 150, 200, size=24) def f(): g() Label("I'm happy", 225, 200, size=24) [1 point] a. 'Hi!' b. I'm happy c. I'm happy Hi! d. Hi! I'm happy

Console

. Which of the following tools can help you find out details about a syntax error? [1 point] a. Autograder b. Console c. Inspector d. Code Editor

b

. Which of the functions is called when z = 12?if (z < 12): drawPolygon(z) elif (z == 12): sayHi() else: drawOval('yellow') [1 point] a. drawOval b. sayHi c. drawPolygon d. None

C

9. Which shape will be in the back if z = 10?r = Rect(0, 0, 400, 400, fill='orange') c = Circle(200, 200, 30, fill='sienna') s = Star(200, 200, 20, 10, fill='lavender') if (z < 10): r.toFront() elif (z > 10): r.toFront() c.toFront() else: s.toBack() [1 point] a. r -b. c -c. s -d. app

D

Which code draws a line from the bottom-most point to the left-most point of this circle? [1 point]Circle is at 200,200-a. Line(200, 200, 200, 100, 100)-b. Line(200, 225, 175, 200)-c. Line(250, 200, 200, 250)-d. Line(200, 250, 150, 200)

C

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

C

Which of the functions is called when x = 5?if (x > 5): drawStar('red') elif (x == 3): drawCircle('green') else: drawRect('cyan') [1 point] a. drawStar b. drawCircle c. drawRect d. None

d. Oval(300, 150, 200, 150)

Which oval touches the right edge of the canvas but not the bottom edge? [1 point] a. Oval(300, 200, 100, 200) b. Oval(300, 300, 200, 200) c. Oval(300, 100, 100, 300) d. Oval(300, 150, 200, 150)

a

Which properties of the RegularPolygon below correspond to a value of 40 and 6 respectively?h = RegularPolygon(200, 200, 40, 6, fill='pink') [1 point] a. h.radius and h.points b. h.centerX and h.centerY c. h.centerX and h.radius d. h.points and h.radius

A

Which shape is completely transparent? [1 point] a. Rect(50, 50, 100, 100, opacity=0) b. Rect(50, 50, 100, 100, fill='white') c. Rect(50, 50, 100, 100, opacity=45, border='black') d. Rect(50, 50, 100, 100, opacity=100)

A

Which of the following is true about if-elif-else statements? [1 point] a. After using if, an elif can be added as an additional test.-b. The bodies of multiple elif's can run. c. You can use an elif without an if. d. Code in an else body runs if all the tests before it were True.

A

Which of the following results in a call to onKeyPress? [1 point] a. Pressing the 'b' key. b. Releasing the 'b' key. c. Calling onKeyRelease('b') in a test case. d. All of the above.

B

Which of the following shape methods checks if a point is contained in a shape? [1 point] a. hits b. contains c. hitsShape d. containsShape

D

Which of the following shape methods checks if a point is inside the boundary of a shape, no matter what fill the shape has? [1 point] a. hitsShape b. containsShape c. hits d. contains

autograder

Which of the following tools can check if your solution is correct for an exercise?

a

Which of the following would be a legal call for the code below?def drawPrettyStar(numberOfPoints, radius, color): Star(200, 200, radius, numberOfPoints, fill=color) a. drawPrettyStar(5, 30, 'red')-b. drawPrettyStar(5, 'blue', 40)-c. drawPrettyStar('purple', 20, 35)-d. drawPrettyStar('4', '5', blue

6

many shapes are drawn according to the code below?def drawShapes(centerX, centerY, radius, points, color): Star(centerX, centerY, radius, points, fill=color) RegularPolygon(centerX, centerY, radius, points, fill=color) Rect(200, 200, 100, 100, fill=color) drawShapes(300, 200, 20, 6, 'navy') drawShapes(100, 200, 50, 8, 'mediumVioletRed')

d

onMouseRelease will draw a rectangle?def onMouseRelease(mouseX, mouseY): if (mouseX > mouseY): Rect(mouseX, mouseY, 30, 30, fill='cornflowerBlue') -a. onMouseRelease(200, 200)-b. onMouseRelease(100, 300)-c. onMouseRelease(0, 0)-d. onMouseRelease(300, 100)

D

red rectangle being drawn when the mouse is moved in the left half of the canvas and a green rectangle being drawn when the mouse is moved elsewhere? # insert if statement here drawRect('red') else: drawRect('green') a. if (mouseY < 200):-b. if (mouseY < 100):-c. if (mouseX < 100):-d. if (mouseX < 200):

c

will correctly call the helper function sayHi from the onMouseMove function in the code below?def sayHi(centerX, centerY): Label('Hi', centerX, centerY, size=24) def onMouseMove(mouseX, mouseY): # insert code here a. sayHi()-b. sayHi(centerX, centerY)-c. sayHi(mouseX, mouseY)-d. sayHi(mouseX)

D

Both circles in the following image have 'fill='black''. What's the opacity of the circle on the right? [1 point] a. 100 b. 90 c. 75 d. 25

b. It makes the text thicker.

How does a label change if you set 'bold=True'? [1 point] a. It makes the text bigger. b. It makes the text thicker. c. It makes the text slanted. d. It makes the text black.

4

How many shapes are drawn according to the code below?def drawShapes(centerX, centerY, color1, color2): Star(centerX, centerY, 75, 5, fill=color1) Star(centerX, centerY, 40, 10, fill= color2) drawShapes(300, 200, 'purple', 'cornflowerBlue') drawShapes(100, 200, 'mediumVioletRed', 'green')

C

What does the following code draw?def onMousePress(mouseX, mouseY): Circle(mouseX, mouseY, 40, fill='purple', border='black', borderWidth=5) a. A red circle with a purple border b. A purple oval with a black border c. A purple circle with a black border d. A red oval with a black border

b. (50, 150)

What is the leftmost point of the following shape?Oval(150, 150, 200, 100) [1 point] a. (100, 150) b. (50, 150) c. (0, 150) d. (250, 150)

d

What is the value of r.right and r.bottom?r = Rect(100, 50, 30, 20, fill='orange') [1 point] a. r.right = 100, r.bottom = 50 b. r.right = 30, r.bottom = 20 c. r.right = 70, r.bottom = 130 d. r.right = 130, r.bottom = 70

D

Which shape is green at the bottom? [1 point] a. Rect(100, 100, 25, 25, fill=None) b. Rect(100, 100, 25, 25, fill=gradient('green', 'black')) c. Rect(100, 100, 25, 25, fill=gradient('green', 'black', start='top')) d. Rect(100, 100, 25, 25, fill = gradient('black', 'green'))

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

Which shape is not black at the top? [1 point] a. Rect(50, 50, 100, 100, fill='black') b. Rect(50, 50, 100, 100, fill=gradient('black', 'yellow')) c. Rect(50, 50, 100, 100, fill=gradient('yellow', 'black', start='bottom')) d. Rect(50, 50, 100, 100, fill=gradient('yellow', 'black'))

A

Which shape is not specified by the (x, y) coordinates of its center? [1 point] a. Rect b. RegularPolygon c. Circle d. Oval

c

Which shape touches the top edge of the canvas but not the left edge? [1 point] a. Oval(200, 150, 400, 300) b. Oval(100, 150, 400, 400) c. Oval(150, 100, 200, 200) d. Oval(150, 250, 300, 100)

a

Which shape will be in the front if x = 5?r = Rect(0, 0, 400, 400, fill= 'orange') c = Circle(200, 200, 20, fill= 'yellow') s = Star(200, 200, 10, 10, fill= 'lavender') if (x <= 5): r.toFront() elif (x > 5): r.toFront() c.toFront() else: s.toBack() [1 point]-a. r-b. c-c. s-d. app

b

Which will be drawn when we call f(5)?def g(message): Label(message, 175, 200, size=24) def f(x): g('hi') Label(x, 225, 200, size=24) [1 point] a. '5hi' b. 'hi5' c. 'hix' d. '5'

C

following will correctly call the helper function drawCircle from the onMouseDrag function in the code below?def drawCircle(x, y): Circle(x, y, 20, fill='hotPink') def onMouseDrag(mouseX, mouseY): # insert code here-a. drawCircle()-b. drawCircle(x, y)-c. drawCircle(mouseX, mouseY)-d. drawCircle(mouseX)

b

functions is called if the mouse is being moved, without being held, across the canvas def onMouseMove(mouseX, mouseY): drawBigStars(mouseX, mouseY) def onMouseDrag(mouseX, mouseY): drawSmallStars(mouseX, mouseY) a. onMouseDrag and drawSmallStars b. onMouseMove and drawBigStars c. onMouseMove and drawSmallStars-d. onMouseDrag and drawBigStars

D

hich of the following is a shape method of polygons? [1 point] a. toFront b. toBack c. addPoint d. All of the above.

Solif black w grey border

hich of the following is the result of the following code? (Ignoring the letter label)Rect(50, 50, 200, 200) Rect(150, 150, 200, 200, fill='white', border='grey', borderWidth=10) [1 point] A) Solid black w grey border

b

is drawn when the mouse is dragged on the left half of the canvas?def onMouseDrag(mouseX, mouseY): if (mouseX < 200): Star(mouseX, mouseY, 20, 5, fill='purple') else: Circle(mouseX, mouseY, 20, fill='red') -a. Red circles of radius 20-b. Purple stars of radius 20-c. Both red circles and purple stars of radius 20-d. Nothing


Ensembles d'études connexes

Module 3.3: Skewness,Kurtosis and Position

View Set

Chapter 16Lesson 3: Health Concerns and Issues

View Set