Font size
WorksheetsTynker Python Lesson 1-2
Total questions: 30
Worksheet time: 17mins
An identifier cannot begin with a number. Which of the following is NOT a valid identifier?
num
_num
NUM
1num_
An identifier can begin with an underscore (“_”).
True
False
An identifier can begin with a number.
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.
_total
2_count
NUM_COUNT
dollar_sign
Which of the following is a valid function call?
forwad)
tu-left()
forward()
forward(;
Select the following function calls that are invalid.
ford)(
$forDS()
forward()
turn_left()
How would you call a function named “my_function”?
Call my_function()
my_function
my_function))
my_function()
Identifiers in Python are case-sensitive.
True
False
78090 is a valid identifier in Python.
True
False
Select the following invalid identifiers. (Identifiers are only allowed to start with an underscore or letter.)
&ident
1ident
_ident
-ident
How would you move an object forward 3 times?
forward() forward() forward()
forward() * 3
Call_forward() 3 times
forward() {3}
You are not able to call the same function twice in a row.
True
False
You can replace the parentheses on a function call with square brackets.
True
False
The parentheses at the end of a function call are optional.
True
False
'''Which of the following is the correct way to start a multi-line comment?
'''
/*
#
//
Both of the following are valid ways to comment code:
Both of the following are valid ways to comment code:
# hello
# world
' ' 'hello world' ' '
True
False
Which of the following comments are correct? Select all that apply.
// hello
# hello
/*he
llo */
//he
llo//
Commented lines affect the execution of your program.
True
False
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
How many blocks will the character move using the following code?
for i in range(1,5) :
forward()
3
4
5
6
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()
The following "for" loop has correct syntax.
for rang(1,1) :
forward()
True
False
How many times will “function1” be called?
for i in range(10) :
for j in range(10) :
function1()
25
20
50
100
Which is the correct syntax to make a "for" loop run for all numbers from 0 to 10?
for i in range(1,10) :
for i in range(10) :
for i in range(-10) :
for i in range(11) :
The following loop will go from i = 5 to i = 1.
for i in range(5,0,-1)
True
False
"For" loops can increment upwards or downwards.
True
False
Choose the following "for" loops that repeat 5 times. Mark all that apply.
for i in range(5)
for i in range(1,5)
for i in range(5,10)
for i in range(10,2)
Select the invalid "for" loops.
for i in range(5) :
for 2 in range(5) :
for i in range() :
for i in range(5,-1) :
How many times will the following "for" loop execute?
for i in range(10,5,-1) :
20
10
5
0
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
