wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PYTHON -- variables

Total questions: 12

Worksheet time: 7mins

Name
Class
Date
1.

Variable names _____________.

Check all that apply.

a)

must not begin with a number

b)

can only contain the characters A-Z, a-z, 0-9, and _ .

c)

letters must be lower case

d)

letters can be upper case, but NOT at the beginning of the variable name

2.

In Python, can string variables be declared using both single and double quotes?

i.e. name = "Ricky" OR name = 'Ricky'

a)

Yes, they are interchangeable

b)

No, only single quotes can be used

c)

No, only double quotes can be used

d)

No, strings cannot be declared with quotes

3.

In Python, are variable names case-sensitive?

a)

Yes, variable names are case-sensitive

b)

No, variable names are not case-sensitive

c)

Only the first character in the variable name is case-sensitive

d)

Case sensitivity depends on the version of Python

4.

In the following code, what value will be assigned to the variable "cat"?


mouse + cat + dog = "small" + "medium" + "large"

a)

small, medium, large

b)

small

c)

medium

d)

large

e)

Nothing, that operation will throw an error

5.

num = 90

num = 20

print(num)

a)

90

b)

4.5

c)

20

d)

1800

6.

Which of the following options are valid variable names?

Check all that apply.

a)

1st_name

b)

first_name

c)

first Name

d)

f1_name

e)

firstName

7.

Variables are used _________.

a)

to store data

b)

to print data

c)

to produce functions

8.

What does the following Python program print?

x = "Hello World!"

y = "I can code "

z = " In Python"

print( x + y + z)

a)

Hello World! I can code In Python

b)

Hello World!I can code InPython

c)

Hello World! I can codeIn Python

d)

Hello World!I can code In Python

e)

xyz

9.

Why the following variable name invalid for python:


1st_Name = 153156456456415

a)

It includes special characters other than underscore

b)

The variable name starts with a number

c)

Keep names meaningful

d)

There is nothing wrong with this variable name

10.

When each word of the variable name, except the first, starts with a capital letter, it's an example of ________.

a)

Camel Case

b)

Pascal Case

c)

Snake Case

d)

No Case

11.

When each word of the variable name is separated by an underscore character, it's an example of ________.

a)

Camel Case

b)

Pascal Case

c)

Snake Case

d)

No Case

12.

Which of the following options is NOT a valid variable name?

a)

act2

b)

myvar

c)

quiz_3

d)

Grade11A