nerdexam
Cisco

350-701 · Question #270

Refer to the exhibit. What will happen when the Python script is executed?

The correct answer is C. The script will pull all computer hostnames and print them.. The Python script uses the socket.gethostname() function to retrieve the local machine's hostname and then prints it to the console.

Submitted by mateo_ar· Mar 30, 2026Automation and Programmability

Question

Refer to the exhibit. What will happen when the Python script is executed?

Exhibit

350-701 question #270 exhibit

Options

  • AThe hostname will be translated to an IP address and printed.
  • BThe hostname will be printed for the client in the client ID field.
  • CThe script will pull all computer hostnames and print them.
  • DThe script will translate the IP address to FODN and print it

How the community answered

(27 responses)
  • A
    4% (1)
  • B
    15% (4)
  • C
    78% (21)
  • D
    4% (1)

Why each option

The Python script uses the `socket.gethostname()` function to retrieve the local machine's hostname and then prints it to the console.

AThe hostname will be translated to an IP address and printed.

The script uses `socket.gethostname()` to get the hostname directly and then prints it; it does not perform a translation from hostname to IP address using functions like `gethostbyname()`.

BThe hostname will be printed for the client in the client ID field.

The script does not involve any 'client ID field' and is focused on retrieving and printing the local machine's hostname, not client-server interactions of this nature.

CThe script will pull all computer hostnames and print them.Correct

The Python script defines a function `get_computer_hostnames` which, in its current implementation, calls `socket.gethostname()`. This function retrieves the standard hostname of the local machine where the script is executed. The main part of the script then iterates through the list returned by this function (which will contain the local hostname) and prints 'Computer Hostname: [hostname]' for each entry.

DThe script will translate the IP address to FODN and print it

The script retrieves a hostname, not an IP address, and it does not translate an IP address to a Fully Qualified Domain Name (FQDN); it gets the simple hostname of the local machine.

Concept tested: Python socket.gethostname() function

Source: https://docs.python.org/3/library/socket.html#socket.gethostname

Topics

#Python scripting#Network programmability#Hostname retrieval

Community Discussion

No community discussion yet for this question.

Full 350-701 Practice