WorksheetsPA_Datatypes_Indentations2
Total questions: 15
Worksheet time: 8mins
What is the order of precedence for the following operators in Python, from highest to lowest?
**, /, %, +
**, +, /, %
+, %, /, **
/, %, +,**
What will be the output of the following Python expression :
print(10 - 4 * 2 + 3)
11
5
15
9
Which of the following operators in Python has right-to-left associativity?
+
-
**
/
What is the result of the following Python expression?
print(2 ** 3 **2)
64
512
12
36
What will be the output of the following Python expression?
print(15 // 4 % 2)
0
1
3
2
Which of the following is NOT a core data type in Python?
List
Dictionary
Class
Tuple
What is the default return value of a Python function that does not explicitly return any value?
a) 0
b) None
c) False
d) Empty string
Which of the following is an immutable data type in Python?
List
Set
Dictionary
Tuple
What will be the output of the following Python code?
my_string = "Python"
print(my_string[1:4])
Pyth
ytho
yth
Pyt
Which built-in function is used to determine the data type of a variable in Python?
typeof()
datatype()
type()
get_type()
What will be the output of the following code?
x = 10
y = "20"
print(x + y)
30
"1020"
Error
None
Which of the following statements about mutable data types in Python is true?
Their values cannot be changed after creation.
They include integers and strings.
They can be modified in place after assignment.
They are always passed by value.
What is the primary purpose of indentation in Python?
a) To improve code readability for humans.
b) To define blocks of code and indicate their scope.
c) To add decorative styling to the code.
d) It is optional and has no significant impact on code execution.
Which of the following will result in an IndentationError in Python?
def my_function():
print("Hello")
for i in range(5):
print(i)
class MyClass:
def init(self):
self.value = 0
What is the standard and recommended amount of indentation in Python?
2 spaces
4 spaces
8 spaces
Any consistent number of spaces or tabs
