exam questions

Exam 350-401 All Questions

View all questions & answers for the 350-401 exam

Exam 350-401 topic 1 question 349 discussion

Actual exam question from Cisco's 350-401
Question #: 349
Topic #: 1
[All 350-401 Questions]

Running the script causes the output in the exhibit. Which change to the first line of the script resolves the error?

  • A. from ncclient import
  • B. import manager
  • C. from ncclient import *
  • D. import ncclient manager
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
xziomal9
Highly Voted 3 years, 3 months ago
The correct answer is: C. from ncclient import *
upvoted 16 times
d4doppelganger
10 months, 2 weeks ago
It does not work. import ncclient from ncclient import * with ncclient.manager.connect( host='192.168.1.1', port=830, username='root', password='test', allow_agent= False) as m: print(m.get_config('running').data_xml) Traceback (most recent call last): File "<pyshell#10>", line 1, in <module> with ncclient.manager.connect( AttributeError: module 'ncclient' has no attribute 'manager'
upvoted 1 times
RickAO76
8 months, 3 weeks ago
remove your prefix "nclient" from this line. with ncclient.manager.connect(
upvoted 1 times
...
...
danman32
1 year, 5 months ago
I tested this. ncclient import * won't work because ncclient is a package, not a module. Unless the package declares what's included when you use '*' to import the package, nothing is imported. ncclient package doesn't have such a declaration
upvoted 1 times
danman32
1 year, 5 months ago
The only import/function declaration that worked was: from ncclient import manager manager.connect(host=host, port=830, username=user, hostkey_verify=False) With from ncclient import manager ncclient.manager.connect(host=host, port=830, username=user, hostkey_verify=False) did not work, returned that module 'ncclient' had no attribute 'manager' So because the exhibit has ncclient. as a prefix in the name of the function being called, none of the syntactically valid import methods will work.
upvoted 1 times
Kdom07
3 months, 1 week ago
there is no answer that says "from" ncclient import manager. so the only logical choice left would be "C"
upvoted 1 times
...
...
...
...
wifishark
Highly Voted 3 years, 4 months ago
"from ncclient import manager" was the answer https://github.com/ncclient/ncclient
upvoted 15 times
cracanici
3 years, 4 months ago
So is from ncclient import * in this case?
upvoted 4 times
danman32
1 year, 5 months ago
This won't work because ncclient is a package, not a module. The ncclient package does not include statements to indicate what modules will be imported if you import the package with '*'
upvoted 1 times
...
...
sihr23
2 years, 2 months ago
This is the correct answer
upvoted 2 times
...
JohnSmithZhao
1 year, 10 months ago
but the following: with ncclient.manager.connect( need to be changed to: with manager.connect( "from ncclient import manager" will work, otherwise it will NOT work.
upvoted 2 times
...
rlilewis
2 years, 8 months ago
That would be if it were an option, which it's not.
upvoted 3 times
...
...
josi_16
Most Recent 2 weeks ago
Selected Answer: D
D is the correct answer
upvoted 1 times
...
[Removed]
7 months, 3 weeks ago
Selected Answer: C
C is corret It must be from "ncclient import manager", but since we have only these options, we can replace manager with *. It works, but it make the code harder to read and debug. All other options are incomplete.
upvoted 2 times
[Removed]
6 months, 2 weeks ago
.................
upvoted 1 times
...
[Removed]
7 months, 3 weeks ago
"from ncclient import manager"
upvoted 1 times
...
...
[Removed]
8 months ago
i think D is correct
upvoted 1 times
[Removed]
7 months, 3 weeks ago
After revision, i think C is correct
upvoted 1 times
...
...
RickAO76
8 months, 3 weeks ago
tested - pythonic way is going to be "from X import Y" - I really hate to see peeps losing an easy one if they are coming across this. Only viable options will be "from ncclient import manager" <<---- best choice "from ncclient import *" <<----- alternate A - from ncclient import ------ ( 1/2 command ) B - import manager --------- ( the package name is ncclient not manager ) C - from ncclient import * ---- (correct with "from ncclient import manager" being better) D - import ncclient manager ---- not a pythonic way of importing packages, you can import on same line with a comma for different packages (import ncclient, pprint, paramiko, netmiko, clrprint) --- but you CAN not import a module from a package this way.
upvoted 3 times
...
secretuser
9 months, 1 week ago
Selected Answer: D
Correct answer is D. >>> from ncclient import * >>> a = ncclient.manager.connect() Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'ncclient' is not defined >>> import ncclient.manager >>> a = ncclient.manager.connect()
upvoted 2 times
...
RickAO76
9 months, 1 week ago
Selected Answer: C
just fysa - for those that are saying that C is wrong.... from ncclient import * I"m guessing it's related to your Python version - if your in python2 or python3 (these would be the only viable answers) from ncclient import * from ncclient import manager
upvoted 2 times
...
RickAO76
9 months, 1 week ago
Selected Answer: C
I can tell you with 100% certiany that it's C. Only valid choices here would be.... - from ncclient import * (* = wildcard to load all modules in ncclient) - from ncclient import manager (this would only load the manager module) The second being better choice if it was listed, but it's not - only other choice viable is the wildcard.
upvoted 2 times
...
awsguruking
9 months, 4 weeks ago
see why answer is D https://stackoverflow.com/questions/23965201/addressing-python-objects
upvoted 1 times
...
Claudiu1
11 months, 1 week ago
Selected Answer: D
All options are stupidly wrong: The correct options: 1. import ncclient.manager with ncclient.manager.connect(..... 2. from ncclient import manager with manager.connect(........ I will go with answer D and assume that the dut(.) between ncclient and manager was forgotten. It is closer to the provided script
upvoted 1 times
...
IgorLVG
1 year, 1 month ago
the correct answers: from ncclient import manager - Option A. Ref: https://ncclient.readthedocs.io/en/latest/
upvoted 1 times
...
Claudiu1
1 year, 1 month ago
these types of questions are really stupid. Does anyone expect me, as an ENCOR certified technician, to have memorized Python libraries?
upvoted 4 times
...
mgiuseppe86
1 year, 4 months ago
it could be a bad dump paste. I just hope i dont get these questions on my test...
upvoted 1 times
...
Chuckzero
1 year, 4 months ago
The correct answer is D. import ncclient.manager. There was an omission of dot(.) in that python line statement. The "import ncclient" is correct in itself, this imports the ncclient library. The ncclient.manager module provides a higher-level abstraction for managing NETCONF sessions and devices. It simplifies some of the complexities of dealing with NETCONF, such as establishing and managing NETCONF sessions. Use "import ncclient.manager" when you want to streamline the process of connecting to NETCONF devices and managing sessions as shown in the exhibit.
upvoted 2 times
...
PureInertiaCopy
1 year, 5 months ago
Chat GPT's Response: It seems like there is a small syntax error in your code. The attribute error is likely due to the incorrect way you're trying to access the manager attribute from the ncclient module. To resolve this, you should import the manager module explicitly from ncclient. Here's the corrected code with the import statement fixed: python Copy code from ncclient import manager # Import the manager module from ncclient with manager.connect( host='192.168.1.1', port=830, username='root', password='test398101469!', allow_agent=False) as m: print(m.get_config('running').data_xml) # Fix the method name and parentheses In this corrected code, I've added the explicit import statement for the manager module from ncclient, and I've also fixed the method name to get_config (removing the extra parenthesis after m.get) to properly request the running configuration data.
upvoted 1 times
...
HarwinderSekhon
1 year, 6 months ago
Selected Answer: C
C is correcy
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago