Chapter 28: Quiz – Foundational Network Programmability Concepts (Answers) CCNPv8 ENCOR

1. Which two statements describe characteristics of the command line interface (CLI)? (Choose two.)

  • Commands can be scripted.
  • The interface protects against misconigurations.
  • Commands cannot be encrypted.
  • Commands are well known and documented.
  • The command-line interface supports a small number of commands.

Explanation: The command-line interface (CLI), while commonly used, has pros and cons. The pros include commands being well known and documented, a commonly used method, the syntax help available on each command, scripting functionality, and the connection to CLI being encrypted (using SSH). The cons include difficulty of scaling, the very large number of commands, the need to know IOS command syntax, lack of intuitiveness, and that only one command at a time can be executed

2. What is a characteristic of a RESTful API?

  • It is a southbound API.
  • It uses HTTP methods to gather and manipulate data.
  • It facilitates the coniguration changes from a network controller to end devices.
  • It supports a secure data transmission between a remote user and an enterprise network.

Explanation: RESTful APIs use HTTP methods to gather and manipulate data. They are northbound APIs. Because there is a defined structure for how HTTP works, it offers a consistent way to interact with RESTful APIs from multiple vendors.

3. Which characters are used to enclose a JSON key?

  • quotation marks
  • commas
  • square brackets
  • colons

Explanation: JSON keys are on the left side of the colon. They need to be wrapped in double quotation marks, as in “key”, and can be any valid string.

4. Which data format does the Cisco DNA Center controller expect from the REST API for incoming data?

  • XML
  • JSON
  • HTML
  • YAML

Explanation: The Cisco DNA Center controller expects all incoming data from the REST API to be in the JSON format.

5. Which menu across the top of the Cisco DevNet main page provides learning tracks that guide users through various technologies and associated API labs?

  • Events
  • Support
  • Discover
  • Technologies

Explanation: Across the top of the main page are a few menu options, Discover, Technologies, Community, Support, and Events. The Discover page is where users can navigate the different offerings that DevNet has available. Under this tab are subsections for guided learning tracks, which guide users through various technologies and the associated API labs.

6. Which type of API is used to communicate from a network controller to its management software in network automation applications?

  • lower layer
  • upper layer
  • northbound
  • southbound

Explanation: In network automation applications, northbound APIs are often used to communicate from a network controller to its management software.

7. Which character is used to separate JSON key/value pairs?

  • (comma) ,
  • (semi colon) ;
  • (dash) –
  • (forward slash) /

Explanation: Each key/value pair in a series of key/value pairs is separated by a comma, so the middle of a JSON looks like this “key”: “value”, “key”: “value”.

8. What is a difference between the XML and HTML data formats?

  • XML formats data in hexadecimal whereas HTML formats data in binary.
  • XML uses a self-descriptive data structure but HTML uses a standard document structure.
  • XML requires indentation for each key/value pair whereas HTML does not require indentation.
  • XML encloses data within a pair of tags whereas HTML uses a pair of quotation marks to enclose data.

Explanation: XML is a human readable data structure used to store, transfer, and read data by applications. Like HTML, XML uses a related set of tags to enclose data. However, unlike HTML, XML does not use predefined tags or a standard document structure, but rather it uses self-descriptive tags and structure.

9. What is a characteristic of the Yet Another Next Generation (YANG) data model?

  • It uses a list structure.
  • It uses a MIBs structure.
  • It uses a tree structure.
  • It uses the JSON data format.

Explanation: YANG models use a tree structure. Within that structure, the models are similar in format to XML and are constructed in modules. These modules are hierarchical in nature and contain all the different data and types that make up a YANG device model.

10. Which RESTFul operation corresponds to the HTTP GET method?

  • read
  • update
  • patch
  • post

Explanation: RESTful operations correspond to the following HTTP methods (shown to the left with the RESTful operation on the right):

  • POST > Create
  • GET > Read
  • PUT/PATCH > Update
  • DELETE > Delete

11. Which HTTP response status code indicates that the request to update the database is completed?

  • 200
  • 201
  • 400
  • 401
  • 403
  • 404

Explanation: The most common HTTP status codes include the following:

  • 200 – OK (using GET or POST to exchange data with an API successfully)
  • 201 – Created (creating resources by using a REST API call successfully)
  • 400 – Bad Request (The request from the client is failed due to client-side issue.)
  • 401 – Unauthorized (The client is not authenticated to access site or API call.)
  • 403 – Forbidden (The access request is not granted based on the supplied credentials.)
  • 404 – Not Found (The page requested at HTTP URL location does not exist or is hidden.)

12. Which two data formats can RESTCON use when requesting data or responding with data? (Choose two.)

  • XML
  • HTML
  • YAML
  • JSON
  • YANG

Explanation: RESTCONF can be used to access data. The RESTCONF requests and responses can use either JSON or XML structured data formats.

13. What character is used to add comments to Python code?

  • $
  • #
  • %
  • @
  • !

Explanation: The # character is used to enter a comment when coding in Python.

14. A student is learning Python. What is the output of the print function?

user_string1 = \”Good\”
user_string2 = \”Morning! \”
print (user_string2 * 3)

  • Good Morning!
  • Good Morning! Good Morning! Good Morning!
  • Morning! Morning! Morning!
  • Good Morning! Morning! Morning!

Explanation: The print() function with the *3 multiplier would create one large string of Morning! Morning! Morning!

“Do I Know This Already?” Quiz Answers:

1. True or false: Python is considered one of the most difficult programming languages to learn and adopt.

  • True
  • False

Explanation: Python is one of the easier programming languages to learn and adopt.

2. To authenticate with Cisco’s DNA Center, which type of HTTP request method must be used?

  • PUT
  • PATCH
  • GET
  • POST
  • HEAD

Explanation: To authenticate to the Cisco DNA Center controller, a POST operation must be used. This is because the login credentials need to be sent to the controller to be verified.

3. What does CRUD stand for?

  • CREATE, RESTORE, UPDATE, DELETE
  • CREATE, READ, UPDATE, DELETE
  • CREATE, RETRIEVE, UPDATE, DELETE
  • CREATE, RECEIVE, UPLOAD, DOWNLOAD
  • CREATE, RECEIVE, UPLOAD, DELETE

Explanation: CRUD stands for CREATE, READ, UPDATE, and DELETE. These are the common actions associated with the manipulation of data. For example, a database uses these actions.

4. When using the Cisco vManage Authentication API, what is the Headers Content Type that is used?

  • MD5
  • X-Auth-Token
  • SSH
  • x-www-form-urlencoded
  • JSON

Explanation: Cisco vManage uses the Headers Content-Type x-www-form-urlencoded. X-Auth-Token is for Cisco DNA Center.

5. Which of the following is in JSON data format?

a.

{
   "user": "root",
   "father": "Jason",
   "mother": "Jamie",
   "friend": "Luke"
}

b.

<users>
      <user>
        <name>root</name>
      </user>
      <user>
        <name>Jason</name>
      </user>
      <user>
        <name>Jamie</name>
      </user>
      <user>
        <name>Luke</name>
      </user>
    </users>

c.

root
Jason
Jamie
Luke

d.

[users[root|Jason|Jamie|Luke]]

Explanation: A JSON data format is built from key/value pairs. For example, “father”: “Jason” is a key/value pair, where father is the key, and Jason is the value.

6. What is the HTTP status code for Unauthorized?

  • 201
  • 400
  • 401
  • 403
  • 404

Explanation: The HTTP status code 401 means Unauthorized—referring to incorrect login credentials or not having valid authentication to a destination. The following table lists more HTTP status codes.

HTTP Status
Code
Result Common Reason for This Code
200 OK Using GET or POST to exchange data with an API
201 Created Creating resources using a REST API call
400 Bad Request Request failed due to client-side issue
401 Unauthorized Client not authenticated to access site or API call
403 Forbidden Access not granted based on supplied credentials
404 Not Found Page at HTTP URL location does not exist or is hidden

7. In Python, why would you use three quotation marks in a row? (Choose two.)

  • To begin a multiple-line string
  • To start a function
  • To represent a logical OR
  • To end a multiple-line string
  • To call a reusable line of code

Explanation: Python uses quotation marks in a row to begin and end a multiple-line string, such as for a long comment.

8. Which of the following is a Python dictionary?

a.

dnac = {
    "host": "sandboxdnac.cisco.com",
    "port": 443,
    "username": "devnetuser",
    "password": "Cisco123!"
}

b.

[users[root|Jason|Jamie|Luke]]

c.

def dnac_login(host, username, password):
    url = "https://{}/api/system/v1/auth/token".
          format(host)
    response = requests.request("POST", url,
               auth=HTTPBasicAuth(username, password),
               headers=headers, verify=False)
    return response.json()["Token"]

d.

print(dnac_devices)

Explanation: Python uses curly braces ({}) as one way to signify a dictionary.

9. Which of the following are Python functions? (Choose two.)

a.

dnac = {
    "host": "sandboxdnac.cisco.com",
    "port": 443,
    "username": "devnetuser",
    "password": "Cisco123!"
}

b.

[users[root|Jason|Jamie|Luke]]

c.

def dnac_login(host, username, password):
    url = "https://{}/api/system/v1/auth/token".
          format(host)
    response = requests.request("POST", url,
               auth=HTTPBasicAuth(username, password),
               headers=headers, verify=False)
    return response.json()["Token"]

d.

print(dnac_devices)

Explanation: Functions can be defined or can already exist within Python. print is a default function, whereas dnac_login is a custom created function.

10. When using the Cisco DNA Center Token API, what authentication method is used?

  • MD5
  • X-Auth-Token
  • SSH
  • Basic authentication
  • JSON

Explanation: Cisco DNA Center uses basic authentication for the initial authentication method. The Headers Content-Type X-Auth-Token is used to send the token back to Cisco DNA Center for future API calls. JSON is the data format of the requests and responses.

11. What is the DevNet Community page used for? (Choose two.)

  • To ask questions
  • To exchange code
  • To access learning labs
  • To access DevNet ambassadors and evangelists
  • To get news on local DevNet events

Explanation: The DevNet Community page is a safe place to interact with other developers and ask questions. DevNet ambassadors and evangelists monitor the page and respond to inquiries and questions.

12. When using GitHub, what is the purpose of a repository? (Choose three.)

  • Provides a place to store a developer’s code
  • Provides a place to store music and photos
  • Gives the option to share a developer’s code with other users
  • Provides documentation on code examples
  • Offers a sandbox to test custom code

Explanation: GitHub is a place to store and share code with other developers as well as provide documentation for that code.

13. Why is using the command-line interface (CLI) to configure a large number of devices considered difficult to scale? (Choose two.)

  • The CLI is prone to human error and misconfi guration.
  • The CLI is quick and effi cient for confi guring many devices simultaneously.
  • Telnet access to the CLI is best practice.
  • The command line is used on a device-by-device basis.
  • Using APIs is considered a legacy method of confi guration.

Explanation: The CLI is difficult to scale when configuring multiple devices at the same time. This is because the CLI is designed for configuration of a single device on a device-by-device basis. Although scripting can help with some of the burden, it is not the best method for scaling. Consistency in configuration from device to device also becomes more difficult to manage as a network grows.

14. Which of the following are part of the YANG model? (Choose two.)

  • Type
  • Leaf
  • Container
  • String
  • Method

Explanation: Leaf and Container are parts of a YANG model. A container can hold multiple leafs.

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x