REST, JSON, and APIs :Using Python to Access Web Data (Python for Everybody Specialization) Answers 2025
Question 1
Who is credited with the REST approach to web services?
✅ Roy Fielding
❌ Bjarne Stroustrup
❌ Daphne Koller
❌ Vint Cerf
❌ Leonard Kleinrock
Explanation: Roy Fielding introduced REST (Representational State Transfer) in his 2000 Ph.D. dissertation at UC Irvine.
Question 2
What Python library do you have to import to parse and handle JSON?
✅ import json
❌ ElementTree
❌ import re
❌ BeautifulSoup
Explanation: The json module is Python’s built-in library for reading and writing JSON data.
Question 3
What is the method used to parse a string containing JSON data so that you can work with it in Python?
✅ json.loads()
❌ json.read()
❌ json.parse()
❌ json.connect()
Explanation: json.loads() parses a JSON-formatted string into a Python dictionary or list.
Question 4
What kind of variable will you get in Python when the following JSON is parsed?
✅ A list with three items
❌ A dictionary with three key/value pairs
❌ A dictionary with one key/value pair
❌ Three tuples
❌ One tuple
Explanation: JSON arrays ([...]) become Python lists.
Question 5
Which of the following is not true about the service-oriented approach?
✅ An application runs together all in one place
❌ Standards are developed where many pairs of applications must work together
❌ An application makes use of services provided by other applications
❌ Web services and APIs are used to transfer data between applications
Explanation: SOA (Service-Oriented Architecture) promotes distributed services, not monolithic apps.
Question 6
Which of these two web service approaches is preferred in most modern service-oriented applications?
✅ REST – Representational State Transfer
❌ SOAP – Simple Object Access Protocol
Explanation: REST is simpler, lighter, and uses standard HTTP, making it the modern default.
Question 7
What library call do you make to append properly encoded parameters to a URL?
✅ urllib.parse.urlencode()
❌ urllib.urlcat()
❌ re.encode()
❌ re.match()
Explanation: urllib.parse.urlencode() safely encodes query parameters (e.g., spaces → %20).
Question 8
What is one advantage of a Service Oriented Architecture?
✅ An application can be developed that makes use of data provided by other organizations
❌ Standalone applications start more quickly
❌ When one part is updated, all parts must be updated
Explanation: SOA allows modular, scalable applications that can integrate data/services from other systems.
Question 9
When accessing API endpoints, what is OAuth typically used for?
✅ Providing security credentials to access the API
❌ Selecting between XML or JSON
❌ Ensuring efficient encoding
❌ Restricting open data
Explanation: OAuth is a standard authorization framework that lets users grant API access securely.
Question 10
What Python package is used to parse XML?
✅ xml.etree.ElementTree
❌ System.Xml.Linq
❌ xml.bind.JAXBContext
❌ DOMDocument
Explanation: xml.etree.ElementTree is Python’s built-in XML parser module.
🧾 Summary Table
| # | ✅ Correct Answer | Key Concept |
|---|---|---|
| 1 | Roy Fielding | Invented REST architecture |
| 2 | import json | JSON parsing module |
| 3 | json.loads() | Parse JSON string to Python object |
| 4 | List with 3 items | JSON array → Python list |
| 5 | Runs together all in one place | Not true for SOA |
| 6 | REST | Modern preferred API style |
| 7 | urllib.parse.urlencode() | Encodes URL parameters |
| 8 | Use data from other orgs | SOA modularity |
| 9 | OAuth for credentials | Secure API access |
| 10 | xml.etree.ElementTree | Parse XML in Python |