A student is learning Python in the interactive interpreter mode. The student issues the commands: What is the result?

IT Questions BankCategory: DevNetA student is learning Python in the interactive interpreter mode. The student issues the commands: What is the result?

A student is learning Python in the interactive interpreter mode. The student issues the commands:

>>> devicenames=[\"RT1\", \"RT2\", \"SW1\", \"SW2\"]
>>> devicenames[-1]

What is the result?

  • ['RT2', 'SW1', 'SW2']
  • SW1
  • RT1
  • SW2
  • an error message

Explanation: In Python, an item in a list can be referenced and manipulated using its index. The first item in a list is indexed as zero, the second is indexed as one, and so on. The last item can also be referenced with an index of [-1].

Exam with this question: 1.3.4 Quiz - Python Review

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments