Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Understanding Python Data Types

Total questions: 27

Worksheet time: 13mins

Name
Class
Date
1.

What are the four primitive data types in Python?

a)

int, float, str, bool

b)

int, float, list, tuple

c)

char, double, list, dict

d)

str, bool, set, complex

2.

Which data type is used to represent whole numbers in Python?

a)

float

b)

string

c)

int

d)

boolean

3.

What is the correct way to declare a variable in Python?

a)

x : 10

b)

var x = 10;

c)

x = 10

d)

let x = 10;

4.

Which of the following is a valid variable name in Python?

a)

1invalidVariable

b)

invalid-variable-name

c)

invalid variable name

d)

valid_variable_name

5.

What function would you use to check the type of a variable in Python?

a)

type()

b)

check_type()

c)

var_type()

d)

get_type()

6.

What is the output of the expression type(3.14)?

a)

b)

c)

d)

7.

Which data type is used to represent text in Python?

a)

int

b)

list

c)

str

d)

float

8.

What is the purpose of the 'str()' function in Python?

a)

The 'str()' function is used to perform mathematical operations.

b)

The 'str()' function is for creating lists in Python.

c)

The 'str()' function is used to define new data types.

d)

The purpose of the 'str()' function is to convert values into their string representation.

9.

Can variable names in Python start with a number?

a)

Variable names can start with a special character

b)

No

c)

Only if they are enclosed in quotes

d)

Yes, they can start with a number

10.

What is the maximum length of a variable name in Python?

a)

Up to 255 characters

b)

Exactly 100 characters

c)

There is no strict limit, but practical limits suggest around 79 characters.

d)

No more than 50 characters

11.

Which of the following is not a primitive data type in Python?

a)

string

b)

list

c)

float

d)

integer

12.

What is the output of the expression len('Hello')?

a)

6

b)

10

c)

4

d)

5

13.

What is the convention for naming variables in Python?

a)

Variable names must always start with a number.

b)

Variable names can only contain letters and numbers.

c)

Variable names in Python should start with a letter or underscore, followed by letters, numbers, or underscores.

d)

Variable names can include special characters like @ and #.

14.

What function would you use to convert a string to an integer in Python?

a)

int()

b)

convert_string()

c)

str_to_int()

d)

parseInt()

15.

Is it possible to use special characters in variable names in Python?

a)

Only certain special characters are allowed in variable names in Python.

b)

Yes, special characters can be used in variable names in Python.

c)

No, special characters cannot be used in variable names in Python.

d)

Special characters can be used if they are enclosed in quotes.

16.

Python is an OOP language.

a)

True

b)

False

17.

What is the output of the following code snippet? ```python print("Hello, Python!") ```

a)

Hello, Python!

b)

"Hello, Python!"

c)

print("Hello, Python!")

d)

Hello, World!

18.

What is the Python code needed to display a word on the screen?

a)

print"hello"

b)

"hello"

c)

print("hello")

d)

print="hello"

19.

What is the Python code needed to ask a user for input?

a)

input("what is your name?")

b)

input="what is your name?"

c)

(input)=what is your name?

d)

input=what is your name?

20.

What does the Python data type str stand for?

a)

string

b)

integer

c)

Boolean

d)

float

21.

What is the Python data type bool stand for?

a)

string

b)

integer

c)

Boolean

d)

float

22.

What is the output of the following code?

x = 25

type(x)

a)

integer

b)

int

c)

<class 'int'>

d)

<class 'number'>

23.

How to get the type of the following Variable?

Val = 12

a)

type(Val)

b)

exec(Val)

c)

print(Val)

d)

help(Val)

24.

Which one of the following is False regarding data types in Python?

a)

In python, explicit data type conversion is possible

b)

Mutable data types are those that can be changed.

c)

Immutable data types are those that cannot be changed.

d)

None of the above

25.

Which of these is not a core data type?

a)

List

b)

Tuple

c)

Dictionary

d)

Class

26.

Which of the following is not a valid integer in Python?

a)

0o123

b)

123

c)

0123

d)

0x123

27.

A variable is a named value that can be changed in the program.

a)

False

b)

True