wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Mastering Python Programming Concepts

Total questions: 10

Worksheet time: 10mins

Name
Class
Date
1.

What are the basic data types in Python?

a)

char, decimal, array, object

b)

string, number, boolean, collection

c)

integer, double, character, map

d)

int, float, str, bool, list, tuple, set, dict

2.

How do you declare a variable in Python?

a)

You declare a variable in Python using: variable_name = value.

b)

declare variable_name as value

c)

variable_name : value

d)

value = variable_name

3.

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

a)

Lists are mutable; tuples are immutable.

b)

Lists are faster than tuples in all operations.

c)

Tuples use parentheses; lists use square brackets.

d)

Lists can only contain numbers; tuples can contain any data type.

4.

Explain the use of 'if', 'elif', and 'else' statements in Python.

a)

'if' checks a condition, 'elif' checks additional conditions, and 'else' executes if none are true.

b)

'if' is for loops, 'elif' is for functions, and 'else' is for imports.

c)

'if' checks for errors, 'elif' is for debugging, and 'else' is for comments.

d)

'if' always executes, 'elif' is optional, and 'else' is mandatory.

5.

What is a for loop in Python?

a)

A for loop is a method for creating classes in Python.

b)

A for loop is a type of variable in Python.

c)

A for loop is used to define functions in Python.

d)

A for loop is a control flow statement that executes code repeatedly for each item in a sequence.

6.

Describe the purpose of a while loop in Python.

a)

A while loop defines a function in Python.

b)

A while loop executes code only once.

c)

A while loop in Python executes a block of code repeatedly as long as a condition is true.

d)

A while loop creates a new variable in Python.

7.

What is the purpose of the 'def' keyword in Python?

a)

'def' is used to define a function in Python.

b)

'def' is used to declare a variable in Python.

c)

'def' is used to create a class in Python.

d)

'def' is used to import modules in Python.

8.

What is the purpose of the 'return' statement in a function?

a)

'return' is used to exit a function and send a value back to the caller.

b)

'return' is used to import libraries in a function.

c)

'return' is used to define a variable inside a function.

d)

'return' is used to create a loop in a function.

9.

What is the purpose of the 'import' statement in Python?

a)

'import' is used to include external modules in a Python program.

b)

'import' is used to create a variable in Python.

c)

'import' is used to execute a loop in Python.

d)

'import' is used to define a function in Python.

10.

What is a dictionary in Python?

a)

A dictionary is a way to create loops in Python.

b)

A dictionary is a collection of key-value pairs.

c)

A dictionary is a type of list that can only contain strings.

d)

A dictionary is a method for defining functions.