200-901 exam dumps

200-901 practice question 132 of 204

Cisco DevNet Associate. Associate level, Cisco. Free question with the correct answer and a full explanation.

200-901 Question 132

Single answer

You are developing a Python script to automate network device configuration using the Cisco DevNet libraries. You need to store the hostname of a device and the corresponding IP address in variables to use them later in the script. Which of the following demonstrates the correct use of variables in Python?

  1. A

    hostname = 'Router1'; ip_address = '192.168.1.1'

  2. B

    var hostname = 'Router1', var ip_address = '192.168.1.1'

  3. C

    hostname: 'Router1', ip_address: '192.168.1.1'

  4. D

    set hostname = 'Router1', set ip_address = '192.168.1.1'

Show answer and explanation

Correct answer: A

Explanation

In Python, variables are created by simply assigning a value to a name using the equal sign (=). Keywords like 'var' or 'set' are not used for variable declaration in Python. This is a fundamental concept for automating network tasks using Python in the Cisco DevNet context.

  • A. Correct.

    This is the correct syntax for declaring and assigning values to variables in Python. Variables are defined by using an equal sign without the use of keywords like 'var' or 'set'.

  • B. Incorrect.

    This is incorrect syntax for Python. The 'var' keyword is used in JavaScript, not in Python.

  • C. Incorrect.

    This is invalid syntax in Python. The colon (:) is not used for variable assignment but for type hints or dictionary keys.

  • D. Incorrect.

    This is incorrect syntax for Python. The 'set' keyword is not used to declare variables in Python.

Timed practice exam

Take a 200-901 practice test under exam conditions

75 questions in 120 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam