WorksheetsTynker Python 101 Unit Test
Total questions: 50
Worksheet time: 25mins
What do you know about text-based programming languages (e.g., JavaScript, Python)? Have you ever used a text-based programming language?
How would you call a function named “my_function”?
Call my_function()
my_function
my_function))
my_function()
You are not able to call the same function twice in a row.
True
False
The parentheses at the end of a function call are optional.
True
False
A programming language that is widely used in web development, game development, and scientific research. It is known for being highly readable and uncluttered, using whitespace indentation instead of curly braces or keywords.
(a)
Write sentences to answer questions
Why is it important that programmers follow the same conventions for naming things in code?
Write sentences to answer questions
What is an algorithm? How does solving a puzzle in Tynker require creating an algorithm?
The set of rules that govern how a language is structured.
(a)
Write sentences to answer questions
What happens if you don’t follow the rules in English (for example, by not capitalizing the first word of a sentence or using a double negative) versus when you don’t follow the rules of Python (for example, by naming an identifier with a reserved word)?
An instruction that you give the computer.
(a)
A unique name that you can refer to later.
(a)
Identifiers are only allowed to start with an underscore or letter.
True
False
In Python, an identifier may begin with an underscore or a letter. Which of the following is a valid identifier? Select all that apply.
dollar_sign
NUM_COUNT
_total
2_count
A naming convention in Python and other languages. Variable and function names (identifiers) cannot have spaces in them
(a)
What will display when you Play these commands?
# The next line is commented out and won't run
# turn_right()
The next line is commented out and won't run
turn_right()
both lines
Nothing
What will display when you Play these commands?
print("Hello")
# print("Hello there")
Hello
Hello there
both lines
Nothing
What will display after you Play this code?
'''
The rain in Spain
Stays mainly in the Plain
'''
print("My Fair Lady")
The rain in Spain
Stays mainly in the Plain
My Fair Lady
both lines
Nothing
Make the character jump over a gap and land on the other side.
jump_over();
jump_up()
jump()
Jump()
Launch an arrow that moves 5 blocks in the direction the character is facing.
Fire();
fire();
fire_forward()
fire()
Turn the character to the right.
turn_right()
turn_right();
turnRight();
turnRight()
Move the character one step forward.
forward();
Forward()
forward()
forward_()
Turn the character to the left.
turn_left();
turn_left()
turnLeft();
turnLeft()
Which of the following is a valid function call?
forwad)
tu-left()
forward()
forward(;
In Python, an identifier may begin with an underscore or a letter. Which of the following is a valid identifier? Select all that apply.
_total
2_count
NUM_COUNT
dollar_sign
You can replace the parentheses on a function call with square brackets.
True
False
'''Which of the following is the correct way to start a multi-line comment?
'''
/*
#
//
What is the error in this code?
What is the error in this code?
''' This function does something '''
def foo() :
print("hello world") ''' prin
The single line comment must use # instead of '''
The end of the multi-line comment cannot be on its own line
The beginning and end of the multi line comments are incorrect
All answers are errors in the code
When would you use an "if-else" statement over an "if" statement?
When you want to stop running code once the condition is false
When you want to run different code if a condition is false
When you want to run code and then check if the condition is true after
They have the exact same function
There is no difference between an "if" statement and an "if-else" statement.
True
False
When running this code, what will the character do if there is an enemy?
if not enemy_in_sight() :
fire()
fire
nothing
walk forward
jump
What function do you use to create a new Turtle object?
turtle.Screen()
turtle.Turtle()
turtle.penup()
turtle.goto()
Which of the following code sets the screen's color to red?
screen.color("red")
screen.make("red")
screen.hide("red")
screen.bgcolor("red")
How would you move an object forward 3 times?
forward() forward() forward()
forward() * 3
Call_forward() 3 times
forward() {3}
"For" loops can increment upwards or downwards.
True
False
Why should you indent your code?
In Python, the program’s execution changes based on whether you indent or not
Code that is not indented properly will produce syntax errors
It is much easier to read indented code
All of the above
Which "for" loop will move your character 5 times?
for i in range(1,5) : forward()
for i in range(5) : forward()
for i in range(1,3) : forward()
for i in range(2,5) : forward()
