Font size
S
M
L
XL
WorksheetsDjango Final Quiz
Total questions: 99
Worksheet time: 2hrs 39mins
Name
Class
Date
1.
What is the primary protocol used by web browsers to communicate with web servers?
a)
FTP
b)
SMTP
c)
HTTP
d)
SSH
2.
Which port number is commonly used for HTTP communication?
a)
21
b)
25
c)
80
d)
443
3.
What is the function of the 'GET' method in HTTP?
a)
Modify a resource
b)
Retrieve a resource
c)
Delete a resource
d)
Create a new resource
4.
In a URL, what does the 'protocol' specify?
a)
The port number to use
b)
The method of data transfer
c)
The IP address of the server
d)
The type of resource
5.
What is the default port for HTTPS communication?
a)
21
b)
80
c)
443
d)
25
6.
Which Python library is used to make simple HTTP requests in the given example?
a)
urllib
b)
requests
c)
socket
d)
sys
7.
What does the 'Content-Type' header in an HTTP response specify?
a)
The length of the response
b)
The format of the response data
c)
The server's IP address
d)
The request method
8.
Which command is used to run a Django development server?
a)
django-admin run
b)
python manage.py runserver
c)
django runserver
d)
manage run
9.
What does the '200 OK' HTTP status code indicate?
a)
Resource not found
b)
Request successful
c)
Unauthorized access
d)
Server error
10.
In Django, what is the default URL for accessing the development server?
a)
http://localhost:8080
b)
http://127.0.0.1:8000
c)
http://127.0.0.1:8080
d)
http://localhost:8000
11.
What does the DOCTYPE declaration in an HTML document specify?
a)
The version of JavaScript used
b)
The document type and version of HTML
c)
The server configuration
d)
The page title
12.
What is the purpose of the <a> tag in HTML?
a)
To define a paragraph
b)
To create a link to another document
c)
To display an image
d)
To add metadata to the document
13.
Which of the following tags is self-closing?
a)
<h1>
b)
<p>
c)
<img>
d)
<div>
14.
What is the function of the href attribute in the <a> tag?
a)
Specifies the text to display in the link
b)
Defines the clickable area of the link
c)
Indicates the destination URL of the link
d)
Provides a tooltip for the link
15.
Which organization is responsible for developing HTML standards?
a)
Internet Engineering Task Force (IETF)
b)
World Wide Web Consortium (W3C)
c)
Internet Corporation for Assigned Names and Numbers (ICANN)
d)
Hypertext Standardization Board
16.
What is the main function of the <ul> and <li> tags in HTML?
a)
To create a table structure
b)
To define an unordered list
c)
To add metadata to the document
d)
To create links to other pages
17.
Which tag is used to create a table in HTML?
a)
<table>
b)
<div>
c)
<form>
d)
<span>
18.
What is the significance of the src attribute in the <img> tag?
a)
Sets the alternative text for the image
b)
Specifies the image's location or source
c)
Defines the style of the image
d)
Describes the image content
19.
Which of the following tags is used to enclose a section of metadata in an HTML document?
a)
<head>
b)
<body>
c)
<footer>
d)
<aside>
20.
What is the primary role of the <html> tag in a web document?
a)
To define the document's main heading
b)
To display the content of the page
c)
To specify that the file is an HTML document
d)
To contain scripts and stylesheets
21.
What does the models.py file define in a Django project?
a)
Views
b)
Templates
c)
Database tables
d)
URLs
22.
Which command is used to create migration files in Django?
a)
python manage.py runserver
b)
python manage.py migrate
c)
python manage.py makemigrations
d)
python manage.py createsuperuser
23.
What is the primary purpose of Django ORM?
a)
To create user interfaces
b)
To handle static files
c)
To map database tables to Python objects
d)
To manage HTTP requests
24.
What does the migrate command in Django do?
a)
Reads models and creates migration files
b)
Executes migration files to create or modify database tables
c)
Generates admin interfaces
d)
Deploys the project to a server
25.
Which field type would you use to store text data up to a specific length in a Django model?
a)
CharField
b)
TextField
c)
EmailField
d)
SlugField
26.
What is the default primary key field in a Django model?
a)
UUIDField
b)
AutoField
c)
BigIntegerField
d)
IntegerField
27.
Which of the following is a valid command to view database tables in SQLite?
a)
.show
b)
.schema
c)
.tables
d)
.view
28.
What does the save() method do in Django ORM?
a)
Deletes a model instance
b)
Retrieves data from the database
c)
Updates or inserts data into the database
d)
Runs database migrations
29.
Which of the following is NOT a valid field type in Django?
a)
CharField
b)
BinaryField
c)
PasswordField
d)
DateTimeField
30.
What does the filter() method do in Django ORM?
a)
Deletes data from the database
b)
Updates specific rows in a table
c)
Retrieves objects matching a specific condition
d)
Executes raw SQL queries
31.
What does the 'Model' represent in the MVC architecture?
a)
User interface elements
b)
Business logic and data
c)
HTML templates
d)
URL routing
32.
In MVC, what is the primary role of the 'View'?
a)
Handling HTTP requests
b)
Managing user sessions
c)
Representing the data
d)
Displaying the user interface
33.
What is the main responsibility of the 'Controller' in MVC?
a)
Storing data in a database
b)
Orchestrating input, output, and logic
c)
Defining routes for URL patterns
d)
Rendering HTML templates
34.
Which of the following files in Django is associated with defining URL routing?
a)
settings.py
b)
urls.py
c)
views.py
d)
models.py
35.
What is the role of the views.py file in a Django application?
a)
Handles HTTP requests and returns responses
b)
Defines database tables
c)
Manages static files
d)
Handles configuration settings
36.
What does the 'Presentation Layer' in MVC refer to in Django?
a)
Model
b)
View
c)
Controller
d)
Database
37.
Which of the following is an example of a 'Model' in Django?
a)
A Python class defining data fields and methods
b)
An HTML template
c)
A database query
d)
A URL pattern
38.
How does Django handle an incoming HTTP request in the MVC architecture?
a)
Directly renders a template
b)
Passes the request through the Model
c)
Routes the request to a View through a Controller
d)
Processes it only in the Controller
39.
In Django, which component handles user input from forms?
a)
Templates
b)
Models
c)
Views
d)
Controllers
40.
What is the primary interaction between the Model and the View in MVC?
a)
View updates the Model directly
b)
Model generates HTML for the View
c)
Model provides data for the View to display
d)
Model receives input from the View
41.
What is the primary role of a view in Django?
a)
Storing user sessions
b)
Handling HTTP requests and returning responses
c)
Defining database schemas
d)
Rendering static HTML files
42.
In Django, what is the purpose of urls.py?
a)
Storing view logic
b)
Routing requests to appropriate views
c)
Configuring the database
d)
Managing templates
43.
What is a typical parameter passed to Django templates for dynamic rendering?
a)
A list of URLs
b)
A context dictionary
c)
A static HTML file
d)
A Python class
44.
Which method is commonly used to return an HTML response from a view in Django?
a)
HttpResponseRedirect
b)
render
c)
redirect
d)
HttpRequest
45.
In Django, which function prevents cross-site scripting (XSS) by escaping user input?
a)
escape
b)
render
c)
reverse
d)
safe
46.
What is the purpose of the {% if ... %} tag in Django templates?
a)
To define template inheritance
b)
To apply CSS styles
c)
To render conditional content
d)
To include external scripts
47.
What does the reverse() function in Django do?
a)
Escapes user input for safety
b)
Redirects HTTP responses
c)
Generates a URL based on a view's name
d)
Includes a template in another template
48.
What is the correct way to pass context data to a template in Django?
a)
Using a URL parameter
b)
Including it in the render() function
c)
Defining it in settings.py
d)
Adding it in the HTML file
49.
Which of the following is an example of template inheritance in Django?
a)
{% block content %}
b)
{% for item in list %}
c)
{% include 'template.html' %}
d)
{% extends 'base.html' %}
50.
How does Django ensure DRY (Don't Repeat Yourself) when generating URLs in templates?
a)
By hardcoding URLs
b)
By using the {% url %} tag
c)
By generating templates dynamically
d)
By storing all URLs in settings.py
51.
What is the primary advantage of using generic views in Django?
a)
To eliminate the need for models
b)
To reduce repetitive code
c)
To manage URL routing
d)
To create custom HTML templates
52.
Which class is used to display a list of objects in Django's generic views?
a)
DetailView
b)
ListView
c)
TemplateView
d)
FormView
53.
What is the default context variable for ListView when using the Horse model?
a)
Horse
b)
horse_object
c)
horse_list
d)
horses
54.
How do you specify the template name for a generic view in Django?
a)
By overriding the template_name attribute
b)
By modifying the settings.py file
c)
By passing it in the URL pattern
d)
By adding it to the model definition
55.
What is the method used in DetailView to retrieve a single object by its primary key?
a)
get_context_data()
b)
get_object()
c)
get_queryset()
d)
filter()
56.
Which design principle do generic views in Django align with?
a)
Convention over Configuration
b)
Single Responsibility
c)
Dependency Injection
d)
Open-Closed Principle
57.
How do you pass a dynamic parameter like pk to a DetailView in Django?
a)
Through the settings.py
b)
Using a URL pattern with a placeholder
c)
By defining it in the model
d)
By adding it in the template
58.
What is the primary method overridden in a ListView to filter the objects displayed?
a)
get_queryset()
b)
get_context_data()
c)
render_to_response()
d)
setup()
59.
Which built-in Django view is used for rendering a static template?
a)
ListView
b)
DetailView
c)
TemplateView
d)
RedirectView
60.
In Django's generic views, what does the context_object_name attribute do?
a)
Defines the object used in the database
b)
Specifies the name of the context variable passed to the template
c)
Configures the URL mapping for the view
d)
Overrides the default query set
61.
What is the primary difference between GET and POST methods in forms?
a)
POST is faster than GET
b)
GET appends data to the URL, while POST sends data in the request body
c)
POST requires CSRF tokens, while GET does not
d)
GET is used for modifying data, while POST retrieves data
62.
Why should GET not be used for modifying data?
a)
It is slower than POST
b)
It has a size limit for data
c)
It is idempotent and can be cached or bookmarked
d)
It cannot handle form submissions
63.
Which HTML element is used to collect text input from users in a form?
a)
<textarea>
b)
<input type='text'>
c)
<select>
d)
<label>
64.
What does the CSRF token prevent in Django?
a)
SQL Injection
b)
XSS Attacks
c)
Cross-Site Request Forgery
d)
Brute Force Attacks
65.
In HTML5 forms, which input type is used for selecting a date?
a)
<input type='text'>
b)
<input type='calendar'>
c)
<input type='date'>
d)
<input type='time'>
66.
What is the purpose of the {% csrf_token %} tag in Django templates?
a)
To generate a session token
b)
To include a CSRF token in forms
c)
To validate user credentials
d)
To encrypt form data
67.
Which status code indicates a POST request was redirected successfully in Django?
a)
200 OK
b)
302 Found
c)
403 Forbidden
d)
404 Not Found
68.
What is the recommended pattern to avoid double submissions in forms?
a)
POST-Redirect-GET
b)
GET-POST-GET
c)
Redirect-POST-Redirect
d)
POST-GET-POST
69.
Which input type in HTML5 is used for numeric data with a range constraint?
a)
<input type='range'>
b)
<input type='number'>
c)
<input type='text'>
d)
<input type='checkbox'>
70.
How does Django handle CSRF tokens in forms?
a)
By validating them against the session data
b)
By encrypting all form data
c)
By storing them in cookies
d)
By generating a new token for each form
71.
What does REST stand for?
a)
Remote Execution Services and Tools
b)
Representational State Transfer
c)
Reliable State Transfer
d)
Random Event Streaming Technology
72.
Which HTTP methods are typically used in RESTful APIs?
a)
CONNECT, TRACE, OPTIONS
b)
GET, POST, PUT, PATCH, DELETE
c)
HEAD, COPY, LINK, UNLINK
d)
MOVE, CHECKOUT, MERGE, REPORT
73.
What is the primary function of serializers in DRF?
a)
Managing URLs
b)
Converting complex data types to JSON
c)
Executing SQL queries
d)
Logging API requests
74.
Which DRF feature is used to restrict abusive API traffic?
a)
Permissions
b)
Throttling
c)
Serializers
d)
Authentication
75.
What is the purpose of using @action in DRF ViewSets?
a)
To create custom routes within a ViewSet
b)
To define API permissions
c)
To generate Swagger documentation
d)
To serialize data
76.
Which tool is commonly used for asynchronous tasks in Django DRF?
a)
Flask
b)
Celery
c)
RabbitMQ
d)
Redis
77.
What is the role of Swagger in Django REST Framework?
a)
Managing API authentication
b)
Logging API requests
c)
Providing interactive API documentation
d)
Caching responses
78.
How does DRF ensure secure API access?
a)
By using serializers for validation
b)
By implementing token or JWT authentication
c)
By enabling caching for responses
d)
By defining detailed logging
79.
What is a best practice for structuring Django DRF projects?
a)
Including all code in a single views.py file
b)
Creating dedicated directories for apps, utilities, and APIs
c)
Hardcoding API endpoints
d)
Avoiding use of serializers for data validation
80.
Which status code is typically used for successful resource creation in REST APIs?
a)
200 OK
b)
201 Created
c)
204 No Content
d)
400 Bad Request
81.
What is a key advantage of using cloud computing for deployment?
a)
Unlimited storage
b)
Dynamic instantiation of servers
c)
Faster local development
d)
Manual configuration
82.
Which deployment tool is used to create isolated Python environments?
a)
Pip
b)
Fabric
c)
Virtualenv
d)
Git
83.
What is the main purpose of the bootstrap.sh script in the deployment process?
a)
To install the operating system
b)
To create a virtual environment and set up deployment tools
c)
To monitor server performance
d)
To manage user authentication
84.
Which of the following is NOT a benefit of retrieving project-specific packages during deployment?
a)
Ability to obtain updated packages
b)
Reduced machine image size
c)
Enhanced security against bugs
d)
Use of public package distribution services
85.
What does the fabfile.py contain in the deployment process?
a)
Database migrations
b)
Server profiles and utility functions for deployment
c)
Python package dependencies
d)
HTML templates
86.
Which tool is used for streamlining the use of SSH in deployments?
a)
Pip
b)
Fabric
c)
Virtualenv
d)
Apache
87.
What is a disadvantage of public package distribution services?
a)
Large file sizes
b)
Security vulnerabilities and potential downtime
c)
Inability to use virtual environments
d)
Dependency on a single version control system
88.
What is the role of deploy in fabfile.py?
a)
To install a new server
b)
To check deployment revision and update the project
c)
To generate virtual environments
d)
To write log files
89.
Why is it important to isolate Python environments during deployment?
a)
To enhance server performance
b)
To manage dependencies for different projects
c)
To ensure data security
d)
To simplify database configuration
90.
What version control system is primarily used in the deployment process described?
a)
Subversion
b)
Git
c)
Mercurial
d)
Bazaar
91.
Which tool is commonly used for configuration management in deployment?
a)
Git
b)
Puppet
c)
Virtualenv
d)
Docker
92.
What is the purpose of using virtualenv in Django deployment?
a)
To manage Python packages and dependencies
b)
To create database backups
c)
To automate migrations
d)
To optimize performance
93.
Which file is typically used for specifying Python package dependencies in Django?
a)
settings.py
b)
requirements.txt
c)
urls.py
d)
manage.py
94.
What is a key benefit of using migrations in Django?
a)
They simplify deployment configurations
b)
They automate Python package installations
c)
They allow for structured and incremental database schema changes
d)
They enable virtual environments
95.
What is the 'Blue/Green Deployment' strategy used for?
a)
Managing application configuration
b)
Performing zero-downtime updates by switching traffic between two environments
c)
Reducing dependency on third-party packages
d)
Automating application testing
96.
What is the primary function of settings.py in Django?
a)
To manage application dependencies
b)
To store application-specific configurations and environment variables
c)
To handle user authentication
d)
To define URL patterns
97.
Why is it recommended to use environment variables in deployment?
a)
To improve application speed
b)
To store sensitive information securely
c)
To simplify database migrations
d)
To enable caching
98.
Which of the following is an essential step before deploying an application?
a)
Creating virtual environments
b)
Writing custom database queries
c)
Backing up existing application data
d)
Optimizing HTML templates
99.
What is the purpose of caching in a Django deployment?
a)
To reduce server costs
b)
To enhance application performance by storing frequently accessed data
c)
To automate database migrations
d)
To manage virtual environments
Reset
