wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PA_Datatypes_Indentations2

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is the order of precedence for the following operators in Python, from highest to lowest?

a)

**, /, %, +

b)

**, +, /, %

c)

+, %, /, **

d)

/, %, +,**

2.

What will be the output of the following Python expression :

print(10 - 4 * 2 + 3)

a)

11

b)

5

c)

15

d)

9

3.

Which of the following operators in Python has right-to-left associativity?

a)

+

b)

-

c)

**

d)

/

4.

What is the result of the following Python expression? 

print(2 ** 3 **2)

a)

64

b)

512

c)

12

d)

36

5.

What will be the output of the following Python expression? 

print(15 // 4 % 2)

a)

0

b)

1

c)

3

d)

2

6.

Which of the following is NOT a core data type in Python? 

a)

List

b)


Dictionary

c)


Class

d)

Tuple

7.

What is the default return value of a Python function that does not explicitly return any value?




a)

a) 0

b)

b) None

c)

c) False

d)

d) Empty string

8.

Which of the following is an immutable data type in Python? 

a)

List

b)

Set

c)

Dictionary

d)

Tuple

9.

What will be the output of the following Python code? 

my_string = "Python"
print(my_string[1:4])

a)

Pyth

b)

ytho

c)

yth

d)

Pyt

10.

Which built-in function is used to determine the data type of a variable in Python? 

a)

typeof()

b)

datatype()

c)

type()

d)

get_type()

11.

What will be the output of the following code? 

x = 10
y = "20"
print(x + y)

a)

30

b)

"1020"

c)

Error

d)

None

12.

Which of the following statements about mutable data types in Python is true?

a)

Their values cannot be changed after creation.

b)

They include integers and strings.

c)

They can be modified in place after assignment.

d)

They are always passed by value.

13.

What is the primary purpose of indentation in Python? 




a)

a) To improve code readability for humans.

b)

b) To define blocks of code and indicate their scope.

c)

c) To add decorative styling to the code.

d)

d) It is optional and has no significant impact on code execution.

14.

Which of the following will result in an IndentationError in Python? 

a)

def my_function():
print("Hello")

b)

c)

for i in range(5):
print(i)

d)

class MyClass:
def init(self):
self.value = 0

15.

What is the standard and recommended amount of indentation in Python?

a)

2 spaces

b)

4 spaces

c)

8 spaces

d)

Any consistent number of spaces or tabs