wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Unit 2 CMU

Total questions: 71

Worksheet time: 53mins

Name
Class
Date
1.

What are the line #'s of the function definition?

a)

38

b)

39

c)

40

d)

41

e)

43

2.

What are the line #'s of the function body?

a)

38

b)

39

c)

40

d)

41

e)

43

3.

What are the line #'s of the function call?

a)

38

b)

39

c)

40

d)

41

e)

43

4.

Select the function parameters

a)

x

b)

y

c)

color

d)

140

e)

'red'

5.

Select the function arguments

a)

x

b)

y

c)

color

d)

140

e)

'red'

6.

What is the function name?

a)

def drawCompartment(x, y, color):

b)

def drawCompartment

c)

drawCompartment

d)

drawCompartment(140, 105, 'red')

7.

The function body must be indented.

a)

True

b)

False

8.

How many times is line 39 executed?

a)

1

b)

8

c)

9

d)

Depends

9.

What is the value of s.radius after the mouse click?

a)

20

b)

30

c)

50

d)

70

10.

What is the value of s.points after the mouse click?

a)

1

b)

9

c)

10

d)

11

11.

What is the value of s.roundness after the mouse click?

a)

4

b)

14

c)

40

d)

100

12.

If the user clicks the mouse at (100, 200). What value is printed for mouseY?

a)

mouseY = 100

b)

mouseY = 101

c)

mouseY = 200

d)

mouseY = 201

13.

If the user clicks the mouse at (100, 200). What value is printed for sky.height?

a)

sky.height = 100

b)

sky.height = 101

c)

sky.height = 200

d)

sky.height = 201

14.

What value is printed for counter.value after the user clicks the mouse?

a)

counter.value = 1

b)

counter.value = 15

c)

counter.value = 16

d)

There is a runtime error

15.

Which of following correctly adds and updates the value of a label 'counter' by 3?

a)

counter.value=counter.value+3

b)

counter.value+=3

c)

counter.value+3

d)

counter.value=3

e)

counter.value=+3

16.

What is the value of s.radius after the mouse click?

a)

20

b)

30

c)

50

d)

70

17.

What is the value of s.points after the mouse click?

a)

1

b)

9

c)

10

d)

11

18.

What is the value of s.roundness after the mouse click?

a)

4

b)

14

c)

40

d)

100

19.

If the user clicks the mouse at (100, 200). What value is printed for mouseY?

a)

mouseY = 100

b)

mouseY = 101

c)

mouseY = 200

d)

mouseY = 201

20.

If the user clicks the mouse at (100, 200). What value is printed for sky.height?

a)

sky.height = 100

b)

sky.height = 101

c)

sky.height = 200

d)

sky.height = 201

21.

What value is printed for counter.value after the user clicks the mouse?

a)

counter.value = 1

b)

counter.value = 15

c)

counter.value = 16

d)

There is a runtime error

22.

What value is printed for counter.value after the user clicks the mouse?

a)

counter.value = 1

b)

counter.value = 15

c)

counter.value = 16

d)

There is a runtime error

23.

What value is printed for counter.value after the user clicks the mouse?

a)

counter.value = 1

b)

counter.value = 15

c)

counter.value = 16

d)

There is a runtime error

24.

Which of following correctly adds and updates the value of a label 'counter' by 3?

a)

counter.value=counter.value+3

b)

counter.value+=3

c)

counter.value+3

d)

counter.value=3

e)

counter.value=+3

25.

Boolean expression: an expression that evaluates to either true or false.

(3 > 2) is

a)

True

b)

False

26.

Boolean expression: an expression that evaluates to either true or false.

(3 < 2) is

a)

True

b)

False

27.

Boolean expression: an expression that evaluates to either true or false.

(3 == 2) is

a)

True

b)

False

28.

Boolean expression: an expression that evaluates to either true or false.

(3 != 2) is

a)

True

b)

False

29.

Boolean expression: an expression that evaluates to either true or false.

(3 >= 2) is

a)

True

b)

False

30.

Boolean expression: an expression that evaluates to either true or false.

(3 <= 2) is

a)

True

b)

False

31.

Boolean values are true or false. Which parameter is a boolean?


Rect(left, top, width, height, fill='black', opacity=100, visible=True)

a)

left

b)

fill

c)

opacity

d)

visible

32.

Comparison operators: operators that compare values.

Boolean expessions contain comparison operators and return True or False.

If statements use boolean expression.

Which symbols are comparison operators?

a)

<= (Less than or equal to)

b)

>= (Greater than or equal to)

c)

== (Equality / Testing 2 values are equal)

d)

!= (Inequality / Testing 2 values are not equal)

e)

= (In Python means setting a value)

33.

A Boolean expression .....

a)

Loops the programs to continue infinitely

b)

Sets everything in it equal to eachother

c)

Checks if something is True or False

d)

Fixes any errors in the line of code

34.

How many values does a Boolean variable have?

a)

1

b)

2

c)

4

d)

infinite

35.

Why would you use a boolean expression?

a)

To create a loop in the program

b)

To locate a bug in the program

c)

To execute the next line in the program

d)

To activate a response with True or False

36.

Which boolean expression can be used to check if someone is 18 years old or older?

a)

age > 18

b)

age < 18

c)

age >= 18

d)

age <= 18

37.

Where can boolean expressions be found?

a)

variables

b)

If statements

c)

By itself

d)

assignment statement

38.

Which numbers for x would cause the boolean expression x <= 14 to be True?

a)

3, 17, 20

b)

1, 11, 14

c)

14, 18, 20

d)

13, 14, 15

39.

Fill in the blank so that people that are 18 years old and older are allowed to vote.

a)

<

b)

>

c)

<=

d)

>=

40.

Where is x > 200 and y > 200?

a)

blue

b)

red

c)

green

d)

yellow

41.

Where is x < 200 and y > 200?

a)

blue

b)

red

c)

green

d)

yellow

42.

Where is x < 200 and y < 200?

a)

blue

b)

red

c)

green

d)

yellow

43.

Where is x > 200 and y < 200?

a)

blue

b)

red

c)

green

d)

yellow

44.

What shapes will be drawn with the call onMousePress(300, 300)?

a)

rectangle

b)

star

c)

circle

d)

oval

45.

What shapes will be drawn with the call onMousePress(100, 100)?

a)

rectangle

b)

star

c)

circle

d)

oval

46.

What shapes will be drawn with the call onMousePress(300, 100)?

a)

rectangle

b)

star

c)

circle

d)

oval

47.

What shapes will be drawn with the call onMousePress(100, 300)?

a)

rectangle

b)

star

c)

circle

d)

oval

48.

What shapes will be drawn with the call onMousePress(100, 300)?

a)

rectangle

b)

star

c)

circle

d)

oval

49.

What shapes will be drawn with the call onMousePress(100, 100)?

a)

rectangle

b)

star

c)

circle

d)

oval

50.

What shapes will be drawn with the call onMousePress(20, 300)?

a)

rectangle

b)

circle

c)

star

d)

oval

51.

What shapes will be drawn with the call onMousePress(250, 100)?

a)

rectangle

b)

circle

c)

star

d)

oval

52.

Which of the following is drawn when the mouse is released?

a)

Two non-touching circles

b)

red circle covering part of the blue circle

c)

blue circle covering part of the red circle

d)

blue circle covering the red circle

e)

red circle covering the blue circle

53.

Which of the following is drawn when the mouse is released?

a)

Two non-touching circles

b)

red circle covering part of the blue circle

c)

blue circle covering part of the red circle

d)

blue circle covering the red circle

e)

red circle covering the blue circle

54.

When the user clicks the mouse, where is Awesome printed?

a)

Top Half of the Canvas

b)

Bottom Half of the Canvas

c)

Right Side of the Canvas

d)

Left Side of the Canvas

55.

When the user clicks the mouse, where is Wonderful printed?

a)

Top Half of the Canvas

b)

Bottom Half of the Canvas

c)

Right Side of the Canvas

d)

Left Side of the Canvas

56.

When the user clicks the mouse, where is Fantastic printed?

a)

Top Half of the Canvas

b)

Bottom Half of the Canvas

c)

Right Side of the Canvas

d)

Left Side of the Canvas

57.

When the user clicks the mouse, where is Amazing printed?

a)

Top Half of the Canvas

b)

Bottom Half of the Canvas

c)

Right Side of the Canvas

d)

Left Side of the Canvas

58.

dotRed.centerX=

a)

dotGreen.centerX

b)

dotYellow.centerX

c)

dotBlue.centerX

59.

dotRed.centerY=

a)

dotGreen.centerY

b)

dotYellow.centerY

c)

dotBlue.centerY

60.

dotGreen.centerX=

a)

400 - dotRed.centerX

b)

400 - dotBlue.centerX

c)

400 - dotRed.centerY

d)

400 - dotBlue.centerY

61.

dotGreen.centerY=

a)

400 - dotRed.centerY

b)

400 - dotBlue.centerY

c)

400 - dotRed.centerX

d)

400 - dotBlue.centerX

62.

Which of the following is a valid function name?

a)

None

b)

1234

c)

drawCircle

d)

def

63.

Given the function shown, which of the following would be a valid function call?

a)

drawBigCircle(“purple”, 20, 300)

b)

drawBigCircle(200, 200, “red”)

c)

drawBigCircle(300, “blue”, 200)

d)

Circle(200, 300, “green”)

64.

Which of the following correctly uses the print function to print to the console?

a)

print helloWorld

b)

print(“hello world”)

c)

print(helloWorld)

d)

print “hello world”

65.

Which of the following shapes does not have a radius property?

a)

Circle

b)

RegularPolygon

c)

Star

d)

Rect

66.

Which of the following is not a fill or border property?

a)

borderStyle

b)

fill

c)

dashes

d)

borderWidth

67.

What do you click to run all of the test cases given in the problem?

a)

Run button

b)

Reset

c)

Test case 1

d)

Autograder

68.

Which of the following is false about global variables?

a)

They should be used sparingly

b)

They should be used all the time

c)

They are used to refer to shapes

d)

They can be used inside and outside of functions

69.

Which of the following is l.value?

a)

‘Hello’

b)

200

c)

20

d)

Label

70.

Which of the following is not a property of all shapes?

a)

bottom

b)

radius

c)

visible

d)

align

71.

Which properties of the given RegularPolygon correspond to a value of 50 and 20 respectively?

a)

s.centerX and s.centerY

b)

s.centerX and s.radius

c)

s.radius and s.centerX

d)

s.centerY and s.radius