wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Variables Quiz

Total questions: 12

Worksheet time: 6mins

Name
Class
Date
1.

What are variables in Python used for?

a)

Storing data values

b)

Performing arithmetic operations

c)

Controlling the flow of a program

d)

Defining functions

2.

How is a variable created in Python?

a)

By using a special command

b)

The moment you first assign a value to it

c)

After declaring its type

d)

By using the 'var' keyword

3.

Do variables in Python need to be declared with a specific type before assigning a value?

a)

Yes, always

b)

No, they do not need to be declared with any particular type

c)

Only for complex data types

d)

Only for integer and string types

4.

Can a variable in Python change type after it has been set?

a)

Yes, it can change type

b)

No, it cannot change type

c)

It can only change to a related type

d)

It can change type only once

5.

What is the result of casting the integer 3 to a string in Python?

a)

'3'

b)

3

c)

'3.0'

d)

3.0

6.

What will be the type of variable y after executing y = int(3) in Python?

a)

str

b)

int

c)

float

d)

list

7.

How do you convert the number 3 to a floating-point number in Python?

(a)  

8.

Which Python function is used to determine the data type of a variable?

a)

type()

b)

typeof()

c)

data_type()

d)

get_type()

9.

If x is assigned the value 5, what will be the output of print(type(x)) in Python?

a)

b)

c)

d)

10.

If y is assigned the value "John", what will be the output of print(type(y)) in Python?

a)

b)

c)

d)

11.

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

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

12.

Are variable names in Python 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