Explore core Python concepts, features, syntax, and tools commonly discussed in interviews. This quiz helps reinforce basic Python knowledge for beginners and job seekers.
Which statement best describes Python's main features?
Explanation: Python is highlighted for its readable syntax, dynamic typing, and large library support. The second and fourth options incorrectly claim Python is compiled and requires manual management. The third option is incorrect because Python provides object-oriented features and is known for its easy syntax.
What is a key difference between a Python list and a tuple?
Explanation: Lists can be changed after creation while tuples cannot. The second option reverses the properties. Both lists and tuples allow duplicates, so the third is incorrect. Lists are ordered, so option four is also incorrect.
What do Python decorators primarily do?
Explanation: Decorators adjust how functions behave by wrapping them, without altering their structure. The other options are unrelated—none involve function behavior modification.
How does a shallow copy differ from a deep copy in Python?
Explanation: A shallow copy shares object references, while a deep copy duplicates the full structure. The second option mistakenly swaps definitions. The third is unrelated; the fourth is incorrect since the two methods behave differently.
What is the main purpose of *args and **kwargs in Python function definitions?
Explanation: They let functions accept variable numbers of both positional and keyword arguments, increasing flexibility. The other options are either unrelated or incorrect regarding their purpose.
Which method does Python use to manage memory automatically?
Explanation: Python uses reference counting and a garbage collector to manage memory, making manual memory management unnecessary. Options two and four are incorrect; option three is not relevant terminology.
In Python, what does the 'is' operator compare?
Explanation: 'is' checks for identity (same object in memory), not value. The second option describes '=='. The third and fourth options do not apply to 'is'.
Which best describes a Python lambda function?
Explanation: Lambda functions are simple anonymous functions created with the 'lambda' keyword. They are not built-in sorters or related to error handling or loop keywords.
What is the difference between a Python module and a package?
Explanation: A module refers to a single .py file, while a package is a directory of modules containing __init__.py. The other options misunderstand the relationship between modules and packages.
Which keywords are commonly used to handle exceptions in Python?
Explanation: Python uses 'try', 'except', 'else', and 'finally' for exception handling. The second and third options list keywords from other languages or made-up ones, and the fourth contains words not used in Python exception handling.