Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python - Variables

Total questions: 31

Worksheet time: 18mins

Name
Class
Date
1.

What type of data is the following?: X = "295.47"

a)

String

b)

Float

c)

Boolean

d)

integer

2.

What type of variable is the following?: Y = False

a)

Float

b)

String

c)

Integer

d)

Boolean

3.

The process of giving a value to a variable is ...

a)

Allocation

b)

Assignment

c)

Comparison

d)

Debugging

4.

Choose valid variable names from the list of options given below:

a)

1st_name

b)

Last_name

c)

first Name

d)

f1_name

e)

firstName

5.

Num = 90

Num = 20

print(Num)

a)

90

b)

4.5

c)

20

d)

1800

6.

In the following code, what type of variable is being created?

foo = "bar"

a)

Integer

b)

Float

c)

String

7.

Which name would be meaningful in keeping a record of someone's high score?

a)

s

b)

hs

c)

score

d)

highScore

8.

Which of the below are acceptable variable names?

a)

result final = 5

b)

result-final = 1

c)

resultFinal = 3

d)

result#final = 4

9.
The correct way to write a variable in Python?
a)
myVariable = 10
b)
my Variable = 10
c)
myVariable is 10
d)
myVariable: 10
10.

Which is the python logo?

a)

Top left

b)

Bottom left

c)

Top right

d)

Bottom right

11.

What do we use variables for?

a)

To store data

b)

Print data

c)

Produce functions

12.

What does int() represent?

a)

internet

b)

integer

c)

intel

d)

input

13.

Choose what / performs.

a)

multiply

b)

add

c)

subtract

d)

divide

14.

What would be printed to the screen for print(z)?

a)

Orange

b)

Banana

c)

Cherry

d)

Hello World!

15.

Why would I get a syntax error?

a)

Line 1 doesn't make sense

b)

Line 2 needs to be indented

c)

No need for quotation marks on line 2

d)

No such thing as an if statement

16.

What will be printed to the screen?

a)

5

b)

10

c)

5 + 10

d)

15

17.

What will be printed to the screen?

a)

5 + John

b)

Syntax error - you cannot add str and int together

c)

John

d)

JohnJohnJohnJohnJohn

18.

What will it print

a)

Error

b)

15

c)

print

d)

'15'

19.
a)

5

b)

Error

c)

10

d)

'10'

20.

What is the name of the variable in this program?

a)

print

b)

colour

c)

input

d)

" "

21.

What will be the output of

print (a + b)

a)

12

b)

3

c)

1 + 2

d)

"a + b"

22.

What will be the output of

print (c + d)

a)

34

b)

7

c)

3 + 4

d)

"3 + 4"

23.

What will be the output of

print (a x b)

a)

12

b)

1

c)

2

d)

"1x2"

24.

What will be the output of

print (b x "d")

a)

b x "d"

b)

dd

c)

2 x 4

d)

8

25.

What will be the output of

print (a x "c")

a)

c

b)

"1c"

c)

"c"

d)

1 x "c"

26.

What will be the output of

print (a x d)

a)

"axd"

b)

"1x4"

c)

"4"

d)

4

27.

To display the following on screen Hello World! the following command should be used:

a)

print(Hello World!)

b)

print("Hello World" + !)

c)

print("Hello World!")

d)

print"(Hello World!)"

28.

Which of the following is a correct variable name?

a)

Act11

b)

11myvar

c)

quiz2$

d)

my-var

29.

Which of the following is a wrong variable name?

a)

act2

b)

myvar

c)

quiz 3

d)

Grade11A

30.

Which of the following is a wrong variable name?

a)

@ct2

b)

age11

c)

_age

d)

first_name

31.

Which of the following is a correct variable name?

a)

11A

b)

Grade11#

c)

Com11

d)

my var