wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CMU AP CSP - Student Created Questions WHS

Total questions: 71

Worksheet time: 36mins

Name
Class
Date
1.
Functions are "self contained" modules of code that accomplish a specific task. Functions usually "take in" data, process it, and "return" a result.
a)
True
b)
False
2.

When you move your mouse, Python calls:

a)

onMouseTrack

b)
onMouseMove
c)

onMoveMouse

d)
onMouseChange
3.

VariableName.fill will change which property of the variable

a)

visible

b)

variable name

c)
x and y values
d)
fill
4.

What is the name of a common debugging technique?

a)
Rubber Duck debugging
b)

Pair Programming

c)

Eraser top tracing

d)

Bug Locus Point

5.

Which of the following is NOT a line property?

a)
x1
b)
lineWidth
c)
border
d)
y2
6.
What are the two types of variables?
a)
Global and local variables
b)
Global and regional variables
c)

Local and regional variables

d)

Scope and local variables

7.
How many parameters must you include in a function declaration?
a)
  1. 0

  2. Functions do not have paramters.

b)

2

c)

No more than 5

d)
Any Amount
8.

Which is the correct way to change the fill to blue?

moon = Circle(200, 170, 100, fill='gold')

a)
moon.fill='blue'
b)

moon.fill='Blue'

c)

moonFill='blue'

d)

moonFill:'Blue'

9.
Position properties are limited to centerX, center Y, and fill.
a)
True
b)
False
10.
Events are associated with an action and supplies input data to a program.
a)
True
b)
False
11.

Events are another name for conditional statements.

a)
True
b)
False
12.
What punctuation is required at the end when you define a variable?
a)

colon

b)

period

c)

semi-Colon

d)

asterisk

13.

Which of the following properties is only used by the Star shape?

a)
Radius
b)
lineWidth
c)
Points
d)
font
14.

How many degrees will the following line rotate when the user clicks on the screen?

a)
45 degrees clockwise
b)
45 degrees anticlockwise
c)
Nothing will happen
d)

The program has a syntax error

15.

Which is the correct Python function definition?

a)

def mousePress( mouseX, mouseY)

b)

Def OnmousePress( mouseX, mouseY)

c)

def OnMousePress( mouseX, mouseY)

d)

def onmousePress (MouseX, MouseY)

16.
What of following is not a position property?
a)
centerX
b)
height
c)
top
d)
right
17.
The body of your if statement needs to be indented
a)
Yes
b)
No
18.

An if statement is a conditional statement
which executes when the conditional evaluates to True

a)
True
b)
False
19.
What does an if statement do?
a)
It runs code if a condition is true.
b)
It runs code if a condition is false
c)

It answers a question

d)

It runs whether a condition is true or false

20.
What can an if statement be classified as?
a)
Conditional statement
b)
Argument Statement
c)
Paramater
d)
Call
21.

Which symbol does not complete a comparison in an if statement

a)
>=
b)
=
c)
<=
d)
!=
22.
what does != mean
a)
equal
b)
always equal
c)
not equal
d)

equivalent

23.

What is the AP Exam equivalent to the

Python comparison symbol

!=

a)

==

b)

<>

c)

d)

!=

24.
Is an if statement considered a function
a)
True
b)
False
25.
What does the != mean in (x != y)?
a)

x is greater than or equal to y

b)

x equal to y

c)

Set x equal to y

d)

x not equal to y

26.

What symbol do you need at the end of an if statement in Python

a)

)

b)
:
c)

;

d)
!
27.

If statements are not case sensitive.

They will run correctly when the whether or not the word if is capitalized.

a)
True
b)
False
28.

How must you write an if statement

a)

IF (-----):

b)

if (-----):

c)

if (------)>

d)

If (-----):

29.
What is another name for a conditional statement
a)
An if statement
b)
A dependable statement
c)

A operator statement

d)

A case statement

30.
What characteristic determines whether an if statement code runs?
a)

When the statement evaluates to undecided

b)

When the statement evaluates to True

c)

When the statement evaluates to False

d)

When the statement evaluates to a variable

31.

Which one is correct?

a)

if (totalCounter.value == 5):

app.background = 'lightGreen'

b)

if (totalCounter.value == 5)

app.background = 'lightGreen'

c)

if (totalCounter.value == 5):

app.background = lightGreen

d)

If (totalCounter.value = 5):

app.background = 'lightGreen'

32.
How do you start a conditional?
a)
if
b)
If
c)

def

d)

Def

33.
Which one of these is a shape property for specifically lines?
a)
Width
b)
top
c)
dashes
d)
opacity
34.

What symbol do we use to compare if two values are equal?

a)
=
b)
!=
c)
d)
==
35.

What is the output of the Python code?

a)

14

b)

12

c)

7

d)

15

36.

Which statement updates X to add one to the value stored in X?

a)

X += 1

b)

X == 1

c)

X + 1

d)

X =+ 1

37.

The property addPoint can only be used with what shape?

a)

Line

b)

Rect

c)

Polygon

d)

Star

38.

What is the error:

a)

"Rect" should be written "rect"

b)

Mousex, Mousey should be written mouseX, mouseY

c)

The comparison in the if statement should be <<

d)

Not enough arguments for the shape Rect

39.

What is wrong with this code?

a)

The variables should be (mouseX, mouseY) instead of (x, y)

b)

The function is onMouseRelease NOT onMousePress

c)

Circles require more arguments than shown

d)

To do a comparison in the if statement, it should read (x == 5) instead of (x = 5)

40.

What is the error in the function?

a)
def should be capitalized
b)

there should be a conditional statement

c)

the variable radius is not defined as a parameter

d)
the function is not called
41.

Which conditional statement would correctly compare mouseX?

a)

if mouseX = 30:

b)
if (mouseX == 30):
c)
IF (mouseX == 30):
d)

if (mouseX = 30):

42.

In python, what is wrong with this conditional statement:

If (x<y):

a)

the I in if is capitalized

b)
there must be a space between the x and y
c)
colon must be spaced apart
d)

the comparison is x<<y not x<y

43.

What is the outcome of the following code?

a)

Arg Count Error: Circle() takes 3 arguments

b)

SyntaxError at line 1: invalid syntax. Perhaps you forgot a comma?

c)

The code works. It creates two circles when the mouse is pressed.

d)

The code works. Only the blue circle is visible when the mouse is pressed.

44.

Which function is written correctly in Python language?

a)

def onMouseClick (mousex, mousey):

b)

def onMousePress (mouseX, mouseY)

c)

Def onMousePress (mouseX, mouseY):

d)

def onMousePress (mouseX, mouseY):

45.

How do you make this rectangle named red visible?

a)

red.rectVisible = True

b)
red.fill = True
c)
red.vision = False
d)
red.visible = True
46.

Find the Error in the Code

a)

The I in if and the E in else should not be capitalized.

b)

onMouseWasPressed
is the correct command, not onMousePress

c)

Incorrect indentation.

The Else: statement should line up under the Circle line

d)

Incorrect number of arguments on the Circle function.

47.

What is the outcome of this conditional statement?

a)

There is an error.
The if statement requires parentheses around the comparison.

b)

If the mouse is clicked on the left half of screen, the eyes and mouth will be chocolate. On the right side, they will be yellow.

c)

There is an error.
If and Else should be capitalized.

d)

There is an error.
The indentation is incorrect. The else should align with the mouth.fill above it.

48.
Which of the following shape methods are correct?
a)
star.isInFront = True
b)
star.isinfront = True
c)
star.IsInFront = True
d)
star.isInFront == True
49.

Which conditional statement is written correctly?
Assume all variables have been correctly defined.

a)
if cookieX < 5:
b)

if (mouseX < 100):

c)
if (centerX <= 325);
d)

If (spikes = 10):

50.
True or False? An if statement must include an else statement.
a)
True
b)
False
51.

Which of the following is correct?

a)
if (star.isInFront = False):
b)
If (star.hits(mouseX, mouseY) == True):
c)
if (dot.hitsShape(star) == True):
d)

If (dot.hits(myshape) == False:

52.

Which of the following is not a method?

a)
.toFront()
b)
.toBack()
c)
.hits()
d)
.toBottom()
53.

The toFront() and toBack() shape methods are built in to CMU Python?

a)
True
b)
False
54.

Will the following code run correctly?

a)
True
b)
False
55.

Would this conditional statement work?

a)

Yes, Everything is written correctly.

b)

No. The statement would end with an error because the

: at the end of the if line is missing.

c)

No. You cannot access the value of the counter using a property statement.

d)

No. The statement would end in an error because the if statement is missing parentheses.

56.
Can their be a space between the if and the condition?
a)
Yes
b)
No
57.

Find the error

a)

Incorrect number of arguments in shape calls

b)

The comparison statement is incorrect

c)
mouseX and mouseY are not defined
d)

else statement is missing a comparison

58.

What is the outcome of this code?

a)

Syntax error

b)

Runtime Error

c)

Logical Error

d)

The code will run with a counter that increases by one each time the mouse is clicked.

59.

Select all the errors in the code.

A. Missing colon(s)

B. Mismatched quotes

C. Indentation error

D. Missing parentheses

a)

A, D

b)

B, C

c)

C

d)

D

60.
== represents a comparison
a)
True
b)
False
61.

When will the body of an if statement NOT run?

a)

When the statement evaluates to both true or false

b)

When the statement evaluates to true

c)

When the statement evaluates to false

d)

When it is called by a function

62.

Is Python code case sensitive?

a)
Yes
b)
No
63.
How many elifs are you allowed to use in Python?
a)
Only 1
b)
Only 2
c)
Maximum of 5
d)
As many as you need
64.
when can you use "elif"
a)
before "if"
b)
after "if"
c)
before "else"
d)
after "else
65.
What is not an example of a custom app property?
a)
app.color
b)
app.background
c)
app.stop()
d)
app.backGround
66.
an elif is used when the first if statement isn't true, but you want to check for another condition.
a)
True
b)
False
67.
After we use if, but before else, we can use elif to add another test that will only be tested if the first test was False.
a)
True
b)
False
68.

what will the value of result be at the completion of this code?

a)
A
b)
B
c)
C
69.

What must precede an elif statement?

a)
An if statment
b)
An else statement
c)

a colon

d)

the word def

70.
True or False? Writing "elif" is the same as writing "else if" in other languages
a)
True
b)
False
71.

what is the correct way to bring an object to the front?

a)
.toFront()
b)
.tofront()
c)

tofront(front)

d)

.toFront(front)