Py4e: Chapter 13- Test Questions &
Answers
Which of the following is not true about the service-oriented approach? ANSWER-An
application runs together all in one place
If the following JSON were parsed and put into the variable x,
{
"users": [
{
"status": {
"text": "@jazzychad I just bought one .__.",
},
"location": "San Francisco, California",
"screen_name": "leahculver",
"name": "Leah Culver",
},
...
what Python code would extract "Leah Culver" from the JSON? ANSWER-
x["users"][0]["name"]
What library call do you make to append properly encoded parameters to the end of a URL like
the following:
, http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=Ann+Arbor%2C+MI
ANSWER-urllib.parse.urlencode()
What happens when you exceed the Google geocoding API rate limit? ANSWER-You
cannot use the API for 24 hours
What protocol does Twitter use to protect its API? ANSWER-OAuth
What header does Twitter use to tell you how many more API requests you can make before you
will be rate limited? ANSWER-x-rate-limit-remaining
What Python library do you have to import to parse and handle JSON? ANSWER-import
json
Which of these two web service approaches is preferred in most modern service-oriented
applications? ANSWER-REST - Representational state transfer
What is the method used to parse a string containing JSON data so that you can work with the
data in Python? ANSWER-json.loads()
What is the name of the Python 2.x library to parse XML data? ANSWER-
xml.etree.ElementTree
Answers
Which of the following is not true about the service-oriented approach? ANSWER-An
application runs together all in one place
If the following JSON were parsed and put into the variable x,
{
"users": [
{
"status": {
"text": "@jazzychad I just bought one .__.",
},
"location": "San Francisco, California",
"screen_name": "leahculver",
"name": "Leah Culver",
},
...
what Python code would extract "Leah Culver" from the JSON? ANSWER-
x["users"][0]["name"]
What library call do you make to append properly encoded parameters to the end of a URL like
the following:
, http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=Ann+Arbor%2C+MI
ANSWER-urllib.parse.urlencode()
What happens when you exceed the Google geocoding API rate limit? ANSWER-You
cannot use the API for 24 hours
What protocol does Twitter use to protect its API? ANSWER-OAuth
What header does Twitter use to tell you how many more API requests you can make before you
will be rate limited? ANSWER-x-rate-limit-remaining
What Python library do you have to import to parse and handle JSON? ANSWER-import
json
Which of these two web service approaches is preferred in most modern service-oriented
applications? ANSWER-REST - Representational state transfer
What is the method used to parse a string containing JSON data so that you can work with the
data in Python? ANSWER-json.loads()
What is the name of the Python 2.x library to parse XML data? ANSWER-
xml.etree.ElementTree