wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Variable and Datatype Quiz

Total questions: 11

Worksheet time: 8mins

Name
Class
Date
1.

Which of the following is a valid Python variable name?

a)

2variable

b)

variable_2

c)

@variable

d)

var-iable

2.

What will be the output of the following code?

a)

int

b)

float

c)

complex

d)

none

3.

Which of these data types is immutable?

a)

List

b)

Set

c)

Dictionary

d)

Tuple

4.

A single-element tuple requires a trailing comma, like (5,)

a)

tuple = (5)

b)

tuple = 5

c)

tuple = (5,)

d)

tuple = [5]

5.

Which of the following statements creates an empty set in Python?

a)

set1 = {}

b)

set1 = set()

c)

set1 = []

d)

set1 = emptyset{}

6.

What will be the output of the following code?

a)

3

b)

4

c)

5

d)

6

7.

What will the following code output?

a)

Pyt

b)

Pyth

c)

Py

d)

Python

8.

Which of these Python collections is unordered?

a)

List

b)

Tuple

c)

Set

d)

String

9.

What will be the output of the following code?

a)

{1, 2, 3, 4}

b)

{3, 1, 2, 3, 4}

c)

{1, 2, 3, 3, 4}

d)

An error will occur

10.

Which of the following data types can hold duplicate values?

a)

Set

b)

Tuple

c)

Dictionary

d)

None of the above

11.

Which operator would you use to check if a value is in a String/List/Set?

a)

in

b)

==

c)

contains

d)

is