wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Basics Quiz

Total questions: 20

Worksheet time: 13mins

Name
Class
Date
1.

What is a variable in Python?

a)

A reserved keyword that cannot be changed.

b)

A container that stores data values, which can be reassigned.

c)

A function that performs calculations.

d)

A data type like int or str.

2.

How do you declare a variable in Python?

a)

By using the 'var' keyword, like var x = 5.

b)

By assigning a value directly, like x = 5.

c)

By specifying the type first, like int x = 5.

d)

Variables must be declared without assignment.

3.

What data type is used for whole numbers in Python?

a)

float

b)

str

c)

int

d)

bool

4.

Which of the following is a floating-point number?

a)

42

b)

"3.14"

c)

3.14

d)

True

5.

What does the type() function do?

a)

Changes the type of a variable.

b)

Returns the data type of a value or variable.

c)

Prints the value of a variable.

d)

Assigns a new value to a variable.

6.

What is the output of print(type("Hello"))?

4 lines
7.

Which operation can you perform on two integers?

a)

Concatenation using +

b)

Addition using +

c)

Repetition using /

d)

Type conversion using type()

8.

What happens when you try to add a string and an integer, like "Age: " + 25?

a)

It works and outputs "Age: 25"

b)

It raises a TypeError.

c)

It converts the int to str automatically.

d)

It outputs 25Age:

9.

How do you concatenate two strings?

a)

Using - operator

b)

Using + operator

c)

Using * operator

d)

Using / operator

10.

What is the data type for True or False values?

a)

int

b)

str

c)

float

d)

bool

11.

Which function converts a string to an integer?

a)

str()

b)

int()

c)

float()

d)

bool()

12.

What are valid variable naming rules in Python? (Select the correct statement)

a)

Can start with a number, like 1var.

b)

Must start with a letter or underscore, no spaces, case-sensitive.

c)

Can use special characters like @ or $.

d)

Must be all uppercase.

13.

What is the output of x = 10; x = 20; print(x)?

a)

10

b)

20

c)

Error

d)

30

14.

How do you check if a variable is a boolean?

a)

Using isinstance(var, bool)

b)

Using type(var) = bool

c)

Using var == True or False

d)

Using bool(var)

15.

What does "dynamic typing" mean in Python?

a)

You must declare types explicitly.

b)

Types are inferred at runtime and can change.

c)

Variables can't change types.

d)

All variables are strings.

16.

What is the result of 10 / 2 in Python?

a)

5 (int)

b)

5.0 (float)

c)

Error

d)

5.

17.

How can you assign multiple variables at once?

a)

a = b = c = 5

b)

a, b, c == 5

c)

a; b; c = 5

d)

Only one at a time.

18.

What type is returned by input() function?

a)

int

b)

float

c)

str

d)

bool

19.

Which of the following causes a NameError?

a)

print(my_var) after my_var = 10

b)

print(my_var) before assigning my_var

c)

my_var = "10" + 10

d)

type(10)

20.

What is None in Python?

a)

A boolean value like False.

b)

A special type representing absence of value.

c)

An integer zero.

d)

An empty string.