
CMU CS Academy Unit 5
Authored by Thomas Martinez
Computers
9th - 12th Grade

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
5 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Read through the following lines of code that contains an error. What should be done to fix the error?
Line 1: a = 1
Line 2:
Line 3: if a = 1:
Line 4: print(“A”)
Line 5: print(“B”)
Line 2 needs to be fixed. Conditional statements use == for equivalent conditions.
Line 5 needs to be fixed. This needs to have an else before it so that it can execute if the condition is not true.
Line 3 is missing parentheses around the condition. Conditional statements always include parentheses.
Line 2 is missing a declaration of the variable b. The conditional statement will have an error with only one variable.
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which of the following is a valid call to the function g and will have f(x) called 3 times?
def g(x,y):
if (x < 5):
f(x)
if (y < 10):
f(x)
f(x)
g(5, 10)
g(10, 5)
g(4, 5)
g(4, 10)
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which of the following calls to onMousePress will do nothing?
def onMousePress(mouseX, mouseY):
if (mouseX != mouseY):
Circle(mouseX, mouseY, 10, fill=’mediumVioletRed’)
onMousePress(100,200)
onMousePress(100,400)
onMousePress(200,100)
onMousePress(300,300)
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which of the following is false about naming functions and parameters?
Names can have spaces.
Names can have digits.
Some names are reserved by python.
Names cannot start with digits.
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
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)
drawPrettyStar(5, 30, ‘red’)
drawPrettyStar(5, ‘blue’, 40)
drawPrettyStar(‘purple’, 20, 35)
drawPrettyStar(‘4’, ‘5’, blue)
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?