Web Development Quiz - Languages Python
Free practice quiz: Web Development (Languages Python). 52 multiple-choice questions with answers and explanations. Play online, no sign-up needed.
Play all 52 questions freeSample questions
Which Python framework is commonly used for building single-page applications (SPAs) with a focus on reactivity?
- Django
- Flask
- Vue.js
- React
Show answer
Answer: C. Vue.js
While Django and Flask are popular Python web frameworks, Vue.js is a JavaScript framework specifically designed for building interactive SPAs with a reactive data-binding system. React is also a JavaScript library for building UIs, but Vue.js is often cited for its ease of integration and reactivity features.
In Python web development, what is a common security vulnerability related to user input and database queries?
- Cross-Site Scripting (XSS)
- SQL Injection
- Cross-Site Request Forgery (CSRF)
- Denial of Service (DoS)
Show answer
Answer: B. SQL Injection
SQL Injection occurs when an attacker inserts malicious SQL code into database queries via user input fields. This can lead to unauthorized access, data modification, or deletion. Using parameterized queries or ORMs helps prevent this.
In the context of web frameworks, what is a 'view' typically responsible for?
- Handling database operations
- Defining the URL structure
- Processing user requests and returning responses
- Managing front-end styling
Show answer
Answer: C. Processing user requests and returning responses
In most web frameworks (like Django and Flask), a 'view' is a Python function or class that handles a specific request, performs necessary logic (e.g., database queries, business logic), and returns an HTTP response, often by rendering a template.
What is the primary advantage of using a microframework like Flask over a full-stack framework like Django for certain projects?
- It offers more built-in features and batteries
- It is generally less flexible and harder to extend
- It has a smaller footprint and allows for greater customization
- It requires a more complex setup process
Show answer
Answer: C. It has a smaller footprint and allows for greater customization
Microframeworks provide the core functionality without imposing many constraints, allowing developers to pick and choose their own libraries and tools. This leads to a more lightweight and customizable application, ideal for smaller projects or APIs where a full-stack framework might be overkill.
What is the purpose of the `__init__.py` file in a Python package directory?
- To define application routes
- To contain the main application logic
- To mark the directory as a Python package and optionally initialize package-level code
- To manage static file assets
Show answer
Answer: C. To mark the directory as a Python package and optionally initialize package-level code
The presence of an `__init__.py` file (even if empty) tells Python that the directory should be treated as a Python package. It can also contain initialization code for the package.