Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Robotic Placement Test

Total questions: 40

Worksheet time: 35mins

Name
Class
Date
1.
Which of the following is a correct file extension for Python files?
a)
.py
b)
.java
c)
.txt
d)
.exe
2.
What will the following code print? print("Hello, world!")
a)
Hello, world!
b)
hello, world!
c)
Hello world
d)
SyntaxError
3.
Which of these is NOT a valid Python variable name?
a)
student_name
b)
2ndPlace
c)
height_cm
d)
_total
4.
What is the correct syntax to create a single-line comment in Python?
a)
// comment
b)
# comment
c)
/* comment */
d)
<!-- comment -->
5.
Which data type would the value 3.14 be in Python?
a)
int
b)
str
c)
float
d)
bool
6.
What is the output of 5 ** 2 in Python?
a)
7
b)
10
c)
25
d)
32
7.
Which keyword is used to define a function in Python?
a)
func
b)
define
c)
def
d)
function
8.
What will the following code output? print(type(True))
a)
<class "int">
b)
<class "str">
c)
<class "bool">
d)
<class "float">
9.
Which function is used to get input from a user in Python?
a)
scanf()
b)
input()
c)
gets()
d)
read()
10.
What operator would you use to check if two values are equal in Python?
a)
=
b)
==
c)
===
d)
eq
11.
Which of these is a Boolean value in Python?
a)
TRUE
b)
Yes
c)
False
d)
Zero
12.
How do you start a new line in a Python string?
a)
\n
b)
/n
c)
<br>
d)
\t
13.
Which built-in function returns the length of a list?
a)
size()
b)
count()
c)
length()
d)
len()
14.
What is the index of the first element in a Python list?
a)
0
b)
1
c)
-1
d)
Depends on list
15.
What will be the result of the expression 10 // 3?
a)
3333
b)
3
c)
4
d)
Error
16.
Which statement correctly assigns the string "Python" to a variable named lang?
a)
lang <- "Python"
b)
let lang = "Python"
c)
lang = "Python"
d)
set lang = Python
17.
Which keyword can be used to create a multi-line string in Python?
a)
""
b)
'
c)

"""

d)
str
18.
What will print(2 + 3 * 4) output?
a)
20
b)
14
c)
24
d)
18
19.
Which of these values is of type str in Python?
a)
42
b)
42.0
c)
"42"
d)
None
20.
What does the len("Python") expression return?
a)
5
b)
6
c)
7
d)
Error
21.
Which keyword is used for an alternative condition in an if statement?
a)
elseif
b)
else if
c)
elif
d)
else
22.
What is the output of the following code? print(list(range(2, 10, 2)))
a)
[2, 4, 6, 8]
b)
[2, 3, 4, 5, 6, 7, 8, 9]
c)
[2, 4, 6, 8, 10]
d)
[2, 4, 6, 8, 10, 12]
23.
Which list method adds a single element to the end of a list?
a)
add()
b)
append()
c)
extend()
d)
insert()
24.

What will be the value of x after this code?

x = 5

x += 3

a)
2
b)
8
c)
53
d)
Error
25.
Which of these loops will execute at least once even if the condition is false?
a)
for loop
b)
while loop
c)
do-while loop
d)
None, Python has no such loop
26.
What does the continue statement do inside a loop?
a)
Terminates the loop completely
b)
Skips the rest of the current iteration
c)
Restarts the program
d)
Throws an error
27.

What does this function return?

def add(a, b=2):

return a + b

result = add(3)

a)
3
b)
5
c)
2
d)
Error
28.
Which of these comparisons evaluates to True?
a)
"5" == 5
b)
5 != 5
c)
5 < 2
d)
5 >= 5
29.
What is printed by the code? my_list = [1, 2, 3] print(my_list[-1])
a)
1
b)
2
c)
3
d)
Error
30.
Which of these statements creates a dictionary in Python?
a)
d = {}
b)
d = []
c)
d = ()
d)
d = "{}"
31.
What will len({1, 2, 2, 3}) return?
a)
4
b)
3
c)
2
d)
Error
32.
Which operator joins two strings in Python?
a)
&
b)
+
c)
,
d)
*
33.
What will be the output? "Python"[1:4]
a)
Pyt
b)
yth
c)
ytho
d)
ython
34.
Which of these keywords is used to handle exceptions?
a)
try
b)
except
c)
finally
d)
All of the above
35.
What is the correct way to open a file called data.txt for reading?
a)
open("data.txt", "w")
b)
open("data.txt", "r")
c)
open("data.txt", "a")
d)
read("data.txt")
36.
What does the expression list(range(5)) produce?
a)
[0, 1, 2, 3, 4]
b)
[1, 2, 3, 4, 5]
c)
[0, 1, 2, 3, 4, 5]
d)
[5, 4, 3, 2, 1]
37.
Which keyword exits a loop prematurely?
a)
exit
b)
stop
c)
break
d)
return
38.
In a function definition, what does *args allow you to do?
a)
Return multiple values
b)
Accept an arbitrary number of positional arguments
c)
Create a global variable
d)
Document the function
39.
Which built-in function converts a string to an integer?
a)
str()
b)
int()
c)
float()
d)
input()
40.
What is the output of bool(0)?
a)
True
b)
False
c)
0
d)
Error