Coursera Answers

Django Web Framework Coursera Quiz Answers

Hello Friends in this article i am gone to share Django Web Framework Coursera Quiz Answers with you..

Enrol Link:ย Django Web Framework

Django Web Framework Coursera Quiz Answers


 

WEEK 1 QUIZ ANSWERS

Knowledge check: Projects and Apps

Question 1)
What is the name of the command-line utility that Django uses internally to create a new Django project?

  • django-admin
  • startproject
  • pip
  • manage.py

Question 2)
Which of the following files are found in Djangoโ€™s project package folder? Select all that apply.

  • models.py
  • urls.py
  • manage.py
  • settings.py

Question 3)
True or false. You donโ€™t need to install the SQLite database for Django to use it as its backend.

  • True
  • False

Question 4)
Is it possible to use a MySQL database with a Django application?

  • Yes
  • No

Question 5)
Complete the following sentence. The ___________ command option of the manage.py script utility is used to launch the Django application.

  • shell
  • startproject
  • runserver
  • startapp

 

Knowledge check: Applications

Question 1)
Which of the following statements are true about a Django app? Select all that apply.

  • A Django app must have at least one model in it.
  • A Django app is reusable.
  • There can be more than one app in a Django project.
  • The app package folder contains a settings.py file where app-specific configuration is defined.

Question 2)
Can the startapp command be used with the django-admin utility?

  • Yes
  • No

Question 3)
Which of the following are features of a view? Select all that apply.

  • The request object is the mandatory argument for the view function.
  • A view is mapped to a URL pattern.
  • The view returns only an HTML response.
  • A view is a user-defined function.

Question 4)
Which of the following statements about the urls.py file in the app folder is false? Select all that apply.

  • The urls.py file is not present in the app folder by default.
  • The urls.py in the apps folder is the same as urls.py in the project folder.
  • The URL patterns in the app are defined with the path() function.
  • The urls.py file at the app-level is included in the urlpatterns list of the project.

Question 5)
True or False. While working on multiple setting files in Django projects, django-admin is preferred over manage.py for running the Django commands in the command line.

  • True
  • False

 

Knowledge check: Web Frameworks and MVT

Question 1)
Which of the following statements apply to a template in Django? Select all that apply.

  • A Django template returns a response to the client browser.
  • A Django template can have blocks of template language syntax in between the HTML script.
  • A Django template is an HTML document.
  • A Django template represents the presentation layer of the web application.

Question 2)
Does a template in Django correspond to the view layer in MVC architecture?

  • Yes
  • No

Question 3)
Which of the following statements about the view() function is correct. Select all that apply.

  • The View function returns a HTTP response to the client.
  • The View function is invoked by the URL dispatcher.
  • The View function interacts with the model.
  • The View function populates the template with context data.

Question 4)
True or False. Django’s view layer performs the role of the Application tier in the MVT architecture.

  • True
  • False

Question 5)
Which of the following statements are true about the model in a Django application? Select all that apply.

  • It reflects the database structure.
  • It represents the data layer of the application.
  • It interacts with the view layer.
  • It defines the processing logic.

 

Visit this link:ย  Module Quiz: Introduction to Django Quiz Answers

 


 

WEEK 2 QUIZ ANSWERS

Knowledge check: Views

Question 1)
Which of the following syntax is valid when using the path() function? Select all that apply.

  • path(‘login/’, name=’login’)
  • path(views.login, ‘login/’)
  • path(‘login/’, views.login)
  • path(‘login/’, views.login, name=’login’)

Question 2)
True or False. The view function calls the render() function to load a template and returns its response to the client.

  • True
  • False

Question 3)
True or False. The correct syntax to import the path() function in the urls.py file is from django.urls import path.

  • True
  • False.

Question 4)
Yes or No. Is it mandatory to define views in the views.py file?

  • Yes
  • No

Question 5)
Which of the following statements about the include() function is true. Select all that apply.

  • The include() function is used to include the URL pattern definitions of an app in the project.
  • The include() function is defined in the django.urls module.
  • You should pass a string representing the path of the app’s urls module to the include() function.
  • The include() function includes, in the URL patterns, the URL mapping to a view function.

 

Knowledge check: Requests and URLs

Question 1)
Complete the following sentence. A view function returns an object of the HttpResponse class. It is imported from________.

  • The django.contrib module
  • The django.urls module
  • The django.db module
  • The django.http module

Question 2)
True or False. More than one URL pattern may be mapped to a single view function.

  • True
  • False

Question 3)
Complete the following sentence. The view function obtains the body parameters in the clientโ€™s request with its ______________ attribute.

  • request.GET
  • request.POST
  • request.FILES
  • request.method

Question 4)
Assuming that the client URL endpoint is http://127.0.0.1:8000/product/keyboard/500/, which of the following statements will correctly parse the path parameters? Select all that apply.

  • path(‘product/<name>/<int:price>’, views.addproduct)
  • path(‘product/<str:name>/<int:price>’, views.addproduct)
  • path(‘product/<name>/<price>’, views.addproduct)
  • path(‘product/<name>/<float:price>’, views.addproduct)

Question 5)
What are the types of parameters that a view receives in a client request? Select all that apply.

  • URL parameters
  • Path parameters
  • Query parameters
  • Body parameters

 

Knowledge check: Handle errors in Views

Question 1)
True or False. To display a standard error message, you should set DEBUG=False in the settings.py file.

  • True
  • False

Question 2)
What is the meaning of an HTTP response with a 404 status code?

  • The request is not completed.
  • The user is not authorized.
  • The access is forbidden.
  • The requested page is not found.

Question 3)
In which module is the HttpResponseNotFound class defined?

  • django.urls module
  • django.http module
  • django.exceptions module
  • django.core.exceptions module

Question 4)
When is the PermissionDenied() exception raised?

  • The user doesn’t have the required permission enabled.
  • The requested object is not found.
  • The view doesn’t exist.
  • The user is not authorized.

Question 5)
Can you override the default error views defined in the django.views.default module?

  • Yes
  • No

 

Visit this link: Module Quiz: Views Quiz Answers

 


 

WEEK 3 QUIZ ANSWERS

Knowledge Check: Models & Migrations

Question 1)
True or False. The on_delete property in the ForeignKey field determines the action to take if the corresponding primary key in the related table is deleted.

  • True
  • False

Question 2)
Complete the following sentence. If multiple objects of one model can be associated with multiple objects of another model, it is the case of a _________________.

  • One-to-many relationship
  • One-to-one relationship
  • Many-to-many relationship
  • Many-to-one relationship

Question 3)
Which of the following statements about the makemigrations command is true? Select all that apply.

  • The makemigrations command creates new migrations based on the changes in the model definitions.
  • The makemigrations command helps with version control.
  • The makemigrations command executes the migration script.
  • The makemigrations command creates a table in the database.

Question 4)
Suppose you create an app called myapp and a model called Users. When you run the migrate command to create a table in the database, what will Django automatically name this table?

  • Django automatically names this table with the name of the model.
  • The name of the table is auto-numbered from 0001 onwards.
  • Django automatically names this table using the app name and model name separated by an underscore, for example myapp_users.
  • Django does not automatically name this table. The table name must be specified using the migrate command.

Question 5)
Complete the following statement. The showmigrations command ______________.

  • shows the pending migrations.
  • shows the Migration class generated by makemigrations.
  • shows the name of the table created.
  • shows the SQL script of migrations to be done.

 

Knowledge Check: Model and Forms

Question 1)
Which of the following is a Built-in Form Field class in Django? Select all that apply.

  • EmailField
  • StringField
  • URLField
  • IntegerField

Question 2)
When the Submit button is pressed on a form created from a template in Django, which of the following requests is triggered by default?

  • GET
  • PUT
  • POST

Question 3)
Which of the following code snippets is correct to import the form properties of a form created using the form class?

  • from django.forms import Form
  • from django.forms import forms
  • from django.forms import Forms

Question 4)
Suppose you create a model for a reservation system that contains fields for name, seats and notes.

When using Model Forms, which of the following is an acceptable value for the field attribute inside the class Meta?

  • Model form
  • “__all__” as well as specific field names: [“name”, “seats”, “notes”]
  • Only “__all__”, field names cannot be specified.
  • Only specific field names can be specified, and no string value such as “__all__”.

Question 5)
True or false. When creating a form using either of the classes, Form or ModelForm, will the argument passed inside the class be the same? For example:

#Create Form
class SampleForm(forms.Form):

#Create ModelForm
class SampleModelForm(forms.Form):
  • Yes
  • No

 

Knowledge Check: Admin

Question 1)
Which of the following actions can be performed using Django Admin in the browser? Select all that apply.

  • Change configuration settings for the Django project
  • Set user permissions for Django users
  • Add and update Django administrative users
  • Configure URLs for specific views

Question 2)
What is the default URL for the Django admin panel?

  • http://127.0.0.1:8000/administrator/
  • http://127.0.0.1:8000/admin/
  • http://127.0.0.1:8000/adminuser/
  • http://127.0.0.1:8000/adminsuperuser/

Question 3)
True or False. When creating a user from the command line, you can define a weak password by bypassing the password validation. However, if you perform this action using the Django admin panel in your browser, you must define a strong password.

  • True
  • False

Question 4)
Which of the following types of users are listed under Permissions in the Django admin panel? Select all that apply.

  • superuser
  • Staff
  • Inactive
  • Active

Question 5)
True or False. Django users are assigned permissions. Over and above this, you can customize permissions for specific models, views, and templates.

  • True
  • False

 

Knowledge Check: Database Configuration

Question 1)
Which of the following is NOT a setting configuration that is added inside the DATABASES option for MySQL?

  • URL
  • PORT
  • ENGINE
  • HOST

Question 2)
Which of the following is an advantage of the SQLite database, which is installed and configured by default with Django projects?

  • SQLite database is comparable to MySQL in terms of scalability, making it quite popular.
  • SQLite database is serverless.
  • SQLite database does not have a user management system.
  • SQLite database is open source and does not require a license for personal use.

Question 3)
Which of the follow databases provide support to easily integrate with the Django applications? Select all that apply.

  • MariaDB
  • SQLite
  • MySQL
  • Postgres

Question 4)
Which of the following is NOT an advantage of using the MySQL database? Select all that apply.

  • Open-Source
  • Scalable
  • Secure
  • Enhanced debugging tools
  • Lightweight

Question 5)
Inside the DATABASES option while configuring the connection for MySQL inside the settings.py file, which of the following optional parameters can be added that will set Initial command to issue to the server upon connection?

  • HOST
  • init_command
  • sql_mode

 

Visit this link: Module Quiz: Models Quiz Answers

 


 

WEEK 4 QUIZ ANSWERS

Knowledge check: Templates

Question 1)
Which of the following configurations inside the settings.py file need to be enabled and set to True for Django to search for templates inside the subdirectory named TEMPLATES?

  • ALLOWED_HOSTS
  • BASE_DIR
  • STATIC_URL
  • APP_DIRS

Question 2)
Complete this sentence. Code reusability in Django is undertaken with the help of partial templates. This is known as _____________________________

  • Template Inheritance
  • Template Language
  • Template Polymorphism

Question 3)
Suppose you are using Django Template Language and you need to count the number of items in a list. Which filter can you use?

  • slice
  • wordcount
  • first
  • length

Question 4)
Which of the following arguments can be passed to the render() function inside the views.py file? Select all that apply.

  • A dictionary of variables to be passed inside the template
  • The request object
  • The HttpResponse object
  • The relative path to the template

Question 5)
True or False. Django template language mainly consists of the following components: Tags, Filters, Comments, and the Template Engine.

  • True
  • False

 

Knowledge check: Working with Templates

Question 1)
Which of the following is the syntax used for ending a comment inside the Django Template Language?

  • {% end comment %}
  • { endcomment }
  • {% endcomment %}
  • {% “endcomment” %}

Question 2)
True or False. In the code below, for the menu object passed inside the template, the syntax for the conditional statement used inside DTL tags is correct.

{% if menu %}
First block of HTML content
{% else %}
Second block of HTML content
{% end if %}
  • True
  • False

Question 3)
What will the correct syntax be for adding variables inside Django using the Django template language?

  • {{ % % }}
  • { }
  • {{ }}
  • {% %}

Question 4)
The csrf token with the syntax {% csrf_token %} stands for Cross-site Request Forgery. What is it primarily used for?

  • The csrf token informs Django that the page visited is secure.
  • The csrf token prepares Django to create Dynamic templates.
  • It’s used for rendering templates using Django template language

Question 5)
True or False. The {% include %} tag imports the base template components in the child template.

  • True
  • False

 

Visit this link: Module Quiz: Templates Quiz Answers

 


 

WEEK 5 QUIZ ANSWERS

Visit this link:ย  Final graded quiz: Django Web Framework Quiz Answers