All Coursera Quiz Answers

Final graded quiz: APIs Quiz Answers

In this article i am gone to share Coursera Course: APIs by Meta Week 4 | Final graded quiz: APIs Quiz Answers with you..

Also visit:  Module quiz: Securing an API in Django REST framework Quiz Answers

 

Final graded quiz: APIs Quiz Answers

Question 1)
A class-based view can accept GET, PUT, POST and DELETE calls by extending RetrieveUpdateDestroyAPIView generic view class.

  • True
  • False

Question 2)
Which of the following decorator functions can be used to display the browsable API view from a function-based view?

  • throttle_classes() decorator
  • permission_classes() decorator
  • api_view() decorator
  • No decorator is needed, DRF handles this automatically.

Question 3)
A model has two fields – id and title. When linked from the serializers, this model always shows the value of the id field. To display the value of the title field instead of the id field, you need to override the __________ method inside the model class.

  • __str__
  • This is not possible
  • __title__
  • __id__
  • __repr__

Question 4)
PascaleCase is the ideal naming convention for writing API endpoint names.

  • True
  • False

Question 5)
How can you keep project dependencies isolated from other projects and avoid conflicts?

  • Use a Piplock file
  • Use a virtual environment
  • Use a global environment
  • Use a requirements.txt file

Question 6)
____ is one of the most popular and most used signing mechanisms used by modern-day API projects.

  • TOKEN
  • HMAC
  • SHA
  • JWT

Question 7)
A watchlist is used to pause the code execution on a specific line and check the values of the current variables.

  • True
  • False

Question 8)
Djoser automatically creates authentication and authorization API endpoints in the DRF based API projects.

  • True
  • False

Question 9)
Where can you validate the input data? Choose all that apply.

  • In the models
  • In the settings.py
  • In the views
  • In the serializer classes

Question 10)
Suppose you created an application that updates the scoreboard for a game twice every day around 3 PM and 8 PM. You created two API endpoints to update and fetch the scorecard data. You have implemented proper caching for these APIs. If 1 million people hit the website every hour, how many times do you need to hit the database in 24 hours as an API developer in an ideal situation?

  • 24 million times
  • Two times
  • 48 million times
  • Four times

 

Question 11)
To accept a GET, PUT, POST and DELETE call, which generic view do you need to extend in your class-based view?

  • RetrieveUpdateDestroyAPIView
  • ListCreateAPIView
  • RetrieveUpdateAPIView
  • CreateAPIView

Question 12)
When a model is linked in a serializer class, it always shows the value of the id field, which was set as the primary key for this model. But what can you do if you want to show the value of the title field instead of the id field?

  • override the __str__ method inside the model and return the value of the title field
  • This is not possible
  • This can only be done by setting the title field as the primary key
  • Override the __str__ method inside the serializer and return the value of the title field

Question 13)
Which of the following are good naming conventions for API endpoints? Choose all that apply.

  • Avoid verbs in the name
  • Use the backslash to indicate relationships
  • Separate words using a hyphen
  • User lowercase names
  • Use pascal case for naming the variables

Question 14)
Which signing mechanism is used to sign an API call?

  • HMAC
  • SHA
  • JWT
  • TOKEN

Question 15)
Which of the following statements about debugging are true? Choose all that apply.

  • Watchlist can be used to examine the value of variables during debugging
  • A breakpoint is used to pause code execution on any line
  • The debug toolbar is always available
  • There are 6 buttons in the debug toolbar inside VS code
  • In the debug toolbar inside VS code there is an SQL panel to check the SQL queries executed for the current request.

Question 16)
What are the benefits of using the Djoser library in your API project? Choose all that apply.

  • It allows the API developers to use JWT
  • It creates authorization endpoints
  • It creates API endpoints to authenticate users and generate tokens
  • It automatically creates API endpoints for user registration
  • It creates API endpoint for a password reset

Question 17)
What are the benefits of caching? Choose all that apply.

  • Increased security
  • Less load on the web server
  • Reduced infrastructure bills
  • Less load on the database
  • Save bandwidth and network resources

Question 18)
It’s good to use a global environment for your Django projects to avoid package conflicts.

  • True
  • False

Question 19)
While debugging, which button you should press in the debug toolbar to go inside the function from the current line and pause the code execution?

  • Step In
  • Stop
  • Continue
  • Step Out
  • Step Over

Question 20)
You are working on a project where the API client needs to send two fields with their values – email and confirmation_email. As an API developer, you need to check if the value for both these fields are the same before saving the email address in the database. How can you do that? Choose all that apply.

  • This can be done using the UniqueTogetherValidator class in the model
  • This can be done in the serializer by using the validate() method
  • This can be done using the UniqueValidator class in the serializer
  • This can be done using the UniqueTogetherValidator class in the serializer
  • This can be done using the UniqueTogetherValidator class in the view file

Question 21)
Caching can be done in the client machine, the database server, the web server and the reverse proxy.

  • True
  • False

Question 22)
What does the following code do in a model? Choose all that apply.

def __str__(self)-> str:
return self.title
  • It helps the serializer to accept only string value for title
  • It converts the title field into a string
  • It converts the model into a string representation
  • It displays the value of the title field of the current model when linked from other models like a StringRelatedField.

Question 23)
The tool __________ can help you to automatically create a virtual environment for your Django projects to keep the dependencies isolated and avoid conflicts with other projects

  • manage.py
  • VS Code
  • Django-admin
  • Curl
  • Pipenv

Question 24)
What are the benefits of signing an API call? Choose all that apply.

  • Signed API calls are sanitized
  • Signed API calls are automatically validated
  • Signed API calls ensure data authenticity
  • Signed API calls can give access to a resource for a certain period of time.
  • Signed API calls can increase API security

Question 25)
To use the browsable API view, what should you do? Choose all that apply.

  • Use the @api_view() decorator
  • Use Django debug toolbar
  • Use a serializer
  • Extend APIView class or any other class that extends the APIView
  • Send HTML response using a HTTPResponse class

Question 26)
Djoser automatically creates the API endpoint _____________ that helps to register new users.

  • /users/me/
  • /auth/
  • /token/login/
  • /users/confirm/
  • /users/

Question 27)
You can use the UniqueTogetherValidator validator inside a _______________ class to ensure the data uniqueness of two or more fields.

  • Model
  • Function-based view
  • Serializer
  • Class-based view