Quiz Details
QZ-20251030-51415
Topics:
Python
Difficulty:
Level 3 - Medium
Questions:
5
Generated:
October 30, 2025 at 08:12 AM
Generated by:
Guest User
Instructions: Select an answer for each question and click "Check Answer" to see if you're correct. Then view the explanation to learn more!
1 What is the output of the following code: print(type([]))?
Correct Answer:
B
Explanation: In Python, an empty list is represented by [], and the type function returns <class 'list'>.
Explanation: In Python, an empty list is represented by [], and the type function returns <class 'list'>.
2 Which of the following is a correct way to define a function in Python?
Correct Answer:
A
Explanation: The correct syntax to define a function in Python is using the 'def' keyword followed by the function name and parentheses.
Explanation: The correct syntax to define a function in Python is using the 'def' keyword followed by the function name and parentheses.
3 What will be the output of the following code: print(2 ** 3 ** 2)?
Correct Answer:
A
Explanation: The expression is evaluated as 2 raised to the power of (3 raised to the power of 2), which equals 2 ** 9 = 512.
Explanation: The expression is evaluated as 2 raised to the power of (3 raised to the power of 2), which equals 2 ** 9 = 512.
4 Which of the following methods can be used to remove an element from a list in Python?
Correct Answer:
C
Explanation: The remove() method is used to remove a specified value from a list. The pop() method can also remove an element at a specific index, but remove() is specifically for value removal.
Explanation: The remove() method is used to remove a specified value from a list. The pop() method can also remove an element at a specific index, but remove() is specifically for value removal.
5 What is the purpose of the 'self' parameter in a class method in Python?
Correct Answer:
C
Explanation: 'self' refers to the instance of the class, allowing access to its attributes and methods. It must be the first parameter in instance methods.
Explanation: 'self' refers to the instance of the class, allowing access to its attributes and methods. It must be the first parameter in instance methods.