wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Basic Python

Total questions: 7

Worksheet time: 4mins

Name
Class
Date
1.

Consider the following Python code

x = "22"

y = "2"

z = x + y

what is the value of z?

a)
an integer with a value of 24
b)
a float with a value of 24
c)
a string with a value of 24
d)
a string with a value of 222
2.

Which of the following variable names are not allowed?

a)
class
b)
type
c)
int
d)
_invalid
3.

What is the output of this code?

a)
[2,4]
b)
2, 4
c)
24
d)
2
4.
Consider the following python code x = 10.0 y = int(x/2 + 1) z = y * 2 what is the value of z
a)
12
b)
12.0
c)
6
d)
6.0
5.

Suppose we have the following list x = [2, 4, 7, 9, 21]

if we want to remove 7 from the list which line of code will fail?

a)
x.pop(2)
b)
x.remove(7)
c)
x.pop(x.index(7))
d)
x.pop(7)
6.
what is the output of the following code x = ["Computer Science", "Programing Skills", "Computer Skills"] y = x[::3][0] z = y[:8:] print(z)
a)
Computer
b)
Science
c)
Programing
d)
Skills
7.
Fill in the blank so that the code outputs the correct result basket = ["apple", "cherry", "orange"] for fruit in basket: if fruit is cherry ____________ print(fruit) # output apple orange
a)
break
b)
continue
c)
stop
d)
None