Which Python module would you use for logging error and debugging messages?
- debug
- logging
- sys
- trace
The logging module is commonly used for logging error and debugging messages in Python. It provides a flexible and configurable way to manage logs in your applications.
Which Python module would you use for measuring the performance of small code snippets?
- benchmark
- datetime
- profiling
- timeit
You would use the timeit module to measure the performance of small code snippets in Python. It provides a simple way to time small bits of Python code and is a useful tool for optimizing code.
Which Python tool would you use to visualize an application’s call stack and identify performance bottlenecks?
- cProfile
- Gunicorn
- Pyflame
- Pygraphviz
Pyflame is a tool for profiling Python applications. It helps visualize the call stack and identify performance bottlenecks. cProfile (Option 1) is a built-in profiler, but it doesn't offer visualization. Gunicorn (Option 3) is a web server. Pygraphviz (Option 4) is for graph visualization, not profiling.
Which Python web framework uses the “Don’t repeat yourself” principle?
- Django
- Flask
- Pyramid
- Tornado
Django is a Python web framework that follows the "Don't repeat yourself" (DRY) principle. DRY encourages developers to avoid duplicating code by providing reusable components and an organized structure.
Which Seaborn function would you use to visualize a bivariate distribution of two variables?
- sns.barplot()
- sns.distplot()
- sns.jointplot()
- sns.plot()
To visualize a bivariate distribution of two variables in Seaborn, you should use the sns.jointplot() function. It creates a scatter plot with marginal histograms and can also display a regression line or a kernel density estimate.
Which Python entity is primarily affected or modified by a metaclass?
- Classes
- Functions
- Modules
- Variables
Metaclasses primarily affect or modify classes. They define how classes themselves are created and behave, allowing you to add, modify, or replace class attributes and methods.
Which Python feature would you use to modify the behavior of a function or method?
- Decorators
- Encapsulation
- Inheritance
- Polymorphism
In Python, decorators are used to modify the behavior of functions or methods. They allow you to add functionality to existing code without modifying its structure. Decorators are often used for tasks like logging, authentication, and more.
Which Python framework allows you to integrate Python back-end code with HTML, CSS, and JavaScript for web development?
- Bottle
- Django
- Flask
- Pyramid
Flask is a micro web framework for Python that allows you to integrate Python back-end code with HTML, CSS, and JavaScript to build web applications. Django, Pyramid, and Bottle are also Python web frameworks, but Flask is known for its simplicity and flexibility, making it suitable for beginners.
Which Python keyword is primarily used in generator functions to yield values?
- break
- continue
- return
- yield
The yield keyword is used in generator functions to yield values one at a time. It allows the function to pause its execution state and resume it when the next value is requested, making generators memory-efficient and suitable for iterating over large datasets.
Which Python keyword is used to define a base class?
- class
- inherit
- parent
- superclass
In Python, the class keyword is used to define a class, including a base class (parent class). You create a base class by defining a class using the class keyword.