QuestionQ11

VerifiedPython/PyEZ

Which two methods can be used to instantiate a list in Python?

Choose two
Explanation

In Python, the single equals sign (=) is the assignment operator used to create and assign a value to a variable, while the double equals sign (==) is a comparison operator that tests equality and does not perform assignment. To instantiate a list, you can either use the list() constructor (interfaces = list()) or assign a list literal enclosed in square brackets (interfaces = ["ge-0/0/0", "ge-10/0/1"]). Both of these use the assignment operator and correctly create a list object. Using == instead of = does not create or assign a list at all, so those options do not instantiate anything.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!