wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Which of the following is a valid Python identifier?

a)

1variable

b)

_variable

c)

variable name

d)

variable-name

2.

Which of the following is not a valid naming convention for Python identifiers?

a)

snake_case

b)

PascalCase

c)

camelCase

d)

kebab-case

3.

What is the maximum length of a Python identifier?

a)

32 characters

b)

64 characters

c)

128 characters

d)

There is no maximum length

4.

Which of the following is not a reserved word in Python and can be used as an identifier?

a)

if

b)

for

c)

and

d)

while

5.

Which of the following is true about Python identifiers?

a)

They are case-sensitive.

b)

They can start with a digit.

c)

They can contain special characters like @ or #.

d)

They can be a Python built-in function name.

6.

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

a)

int

b)

float

c)

string

d)

array

7.

What is the difference between a tuple and a list in Python?

a)

Tuples are mutable, and lists are immutable.

b)

Tuples are ordered, and lists are unordered.

c)

Tuples are enclosed in parentheses, and lists are enclosed in square brackets.

d)

Tuples can contain elements of different data types, while lists can only contain elements of the same data type.

8.

Which data type is used to represent a Boolean value in Python?

a)

bool

b)

boolean

c)

bit

d)

logical

9.

Which data type is used to represent a collection of key-value pairs in Python?

a)

dictionary

b)

set

c)

tuple

d)

array

10.

Which of the following data types is mutable in Python?

a)

int

b)

float

c)

tuple

d)

list

11.

What happens when you modify an immutable object in Python?

a)

The object's value is changed directly.

b)

The object is replaced with a new object that has the modified value.

c)

It is not possible to modify immutable objects in Python.

d)

The modification results in a runtime error.

12.

What is the purpose of comments in Python?

a)

To make the code execute faster.

b)

To mark the end of a code block.

c)

To explain or clarify the code for humans.

d)

To generate error messages during runtime.

13.

Which data type is used to represent a collection of key-value pairs in Python?

a)

dictionary

b)

set

c)

tuple

d)

array

14.

How are single-line comments denoted in Python?

a)

/* ... */

b)

<!-- ... -->

c)

// ...

d)

# ...

15.

Which of the following is an appropriate use case for comments in Python?

a)

Storing important data within comments.

b)

Commenting out large sections of code temporarily.

c)

Creating executable code that runs during runtime.

d)

Changing the behavior of the program based on comments.

16.

What happens to comments when you execute a Python program?

a)

They are completely ignored and not executed.

b)

They are executed as regular code.

c)

They generate runtime errors.

d)

They are executed but have no effect on the program's output.

17.

Can comments span multiple lines in Python?

a)

Yes, using the // symbol.

b)

Yes, using the /* ... */ symbols.

c)

Yes, using triple quotes (''' ... ''') or (# ... #).

d)

No, comments must always be on a single line.

18.

Which operator is used for exponentiation in Python?

a)

^

b)

**

c)

*

d)

//

19.

What is the result of the expression 10 / 3 in Python?

a)

3.33

b)

3

c)

3.0

d)

3.333

20.

What is the result of the expression "Hello" + "World" in Python?

a)

HelloWorld

b)

Hello World

c)

Hello+World

d)

Error: unsupported operand type(s) for +: 'str' and 'str'