Building Web Applications in Django | Week 3

Course Name: Django for Everybody

Sub-course: Building Web Applications in Django

Course Link: Django for Everybody

Sub-course Link: Building Web Applications in Django

These are Building Web Applications in Django Week 3 answers Coursera Quiz


Object Oriented Python

Q1. Which came first, the instance or the class?

  • instance
  • class

Answer: class


Q2. In Object Oriented Programming, what is another name for the attributes of an object?

  • fields
  • methods
  • messages
  • portions
  • forms

Answer: fields


These are Building Web Applications in Django Week 3 Answers Coursera Quiz


Q3. Which of the following is NOT a good synonym for “class” in Python?

  • template
  • direction
  • pattern
  • blueprint

Answer: direction


Q4. What does this Python statement do if PartyAnimal is a class?

  • Copy the value from the PartyAnimal variable to the variable zap
  • Subtract the value of the zap variable from the value in the PartyAnimal variable and put the difference in zap
  • Clear out all the data in the PartyAnimal variable and put the old values for the data in zap
  • Use the PartyAnimal template to make a new object and assign it to zap

Answer: Use the PartyAnimal template to make a new object and assign it to zap


These are Building Web Applications in Django Week 3 Answers Coursera Quiz


Q5. What is the syntax to look up the fullname attribute in an object stored in the variable colleen?

  • $colleen::fullname
  • colleen.fullname
  • $colleen->fullname
  • $colleen[“fullname”]
  • $colleen->$fullname

Answer: colleen.fullname


Q6 .Which of the following statements are used to indicate that class A will inherit all the features of class B?

  • class A inherits B:
  • class A instanceOf B;
  • class A extends B:
  • class A(B):
See also  Building Web Applications in Django | Week 4

Answer: class A(B):


These are Building Web Applications in Django Week 3 Answers Coursera Quiz


Q7. What is “self” typically used for in a Python method within a class?

  • To refer to the instance in which the method is being called
  • To terminate a loop
  • To set the residual value in an expression where the method is used
  • To retrieve the number of parameters to the method

Answer: To refer to the instance in which the method is being called


Q8. What does the Python dir() function show when we pass an object into it as a parameter?

  • It shows the number of parameters to the constructor
  • It shows the parent class
  • It shows the type of the object
  • It shows the methods and attributes of an object

Answer: It shows the methods and attributes of an object


These are Building Web Applications in Django Week 3 Answers Coursera Quiz


Q9. Which of the following is rarely used in Object Oriented Programming?

  • Destructor
  • Constructor
  • Method
  • Inheritance
  • Attribute

Answer: Destructor


Generic Views

Q1. In the class django.views.generic.list.ListView, which of the following methods is called earliest in the process?

  • get_template_names()
  • get_queryset()
  • get_context_data()
  • render_to_response()

Answer: get_template_names()


Q2. In the class django.views.generic.list.ListView, which of the following methods is called latest in the process?

  • get_template_names()
  • get_queryset()
  • get_context_data()
  • render_to_response()

Answer: render_to_response()


These are Building Web Applications in Django Week 3 Answers Coursera Quiz


Q3. In the class django.views.generic.detail.DetailView, which of the following methods is called earliest in the process?

  • dispatch()
  • get_queryset()
  • get_object()
  • render_to_response()

Answer: dispatch()


Q4. In the class django.views.generic.detail.DetailView, which of the following methods is called latest in the process?

  • dispatch()
  • get_queryset()
  • get_object()
  • render_to_response()
See also  Using JavaScript and JSON in Django | Week 4

Answer: render_to_response()


These are Building Web Applications in Django Week 3 Answers Coursera Quiz


Q5. By convention when using an app_name of “abc” and a model of “Dog”, if you use a View that extends django.views.generic.detail.DetailView, what is the file name that will be used for the template?

  • templates/abc/dog_detail.html
  • templates/abc/dog_detail.djtl
  • templates/dog_detail.djtl
  • templates/doc/abc_detail.djtl

Answer: templates/abc/dog_detail.html


Q6. If you want to override the template name chosen by convention in a View that extends django.views.generic.detail.DetailView, what is the name of the class attribute variable that you use?

  • template_name
  • template
  • template_override
  • template_extend

Answer: template_name


These are Building Web Applications in Django Week 3 Answers Coursera Quiz


Q7. By convention when using an app_name of “abc” and a model of “Dog”, if you use a View that extends django.views.generic.list.ListView, what is the name of the context variable that will include all the Dog objects in the template when it is being rendered?

  • dog_list
  • dogs
  • dogs_select
  • dogs.values()

Answer: dog_list


Q8. For the following line in a views.py file
what is the best description of “ListView”?

  • The class that is being extended
  • The class that is being created
  • The name of a view function
  • The first parameter to the render() method

Answer: The class that is being extended


These are Building Web Applications in Django Week 3 Answers Coursera Quiz


Q9. For the following line in a views.py file
class ArticleListView(ListView):
what is the best description of “ArticleListView”?

  • The class that is being extended
  • The class that is being created
  • The name of a view function
  • The first parameter to the render() method

Answer: The class that is being created

See also  Django Features and Libraries | Week 4

Q10. For the following line in a urls.py file
urlpatterns = [
path(”, TemplateView.as_view(template_name=’gview/main.html’))
where would you find the actual code for TemplateView?

  • In the Django source
  • In views.py
  • In settings.py
  • In urls.py

Answer: In the Django source


These are Building Web Applications in Django Week 3 Answers Coursera Quiz


More Weeks of this course: Click Here

More Coursera Courses: http://progiez.com/coursera


These are Building Web Applications in Django Week 3 Answers Coursera Quiz