nerdexam
CompTIA

PT0-002 · Question #319

Within a Python script, a line that states print (var) outputs the following: [{'1' : 'CentOS', '2' : 'Ubuntu'}, {'1' : 'Windows 10', '2' : 'Windows Server 2016'}] Which of the following objects or…

The correct answer is D. A list. A list is a data structure in Python that can store multiple values of different types in a sequential order. A list is created by enclosing the values in square brackets [ ] and separating them by commas. A list can also contain other lists as its elements, creating a nested…

Tools and Code Analysis

Question

Within a Python script, a line that states print (var) outputs the following:

[{'1' : 'CentOS', '2' : 'Ubuntu'}, {'1' : 'Windows 10', '2' : 'Windows Server 2016'}] Which of the following objects or data structures is var?

Options

  • AAn array
  • BA class
  • CA dictionary
  • DA list

How the community answered

(27 responses)
  • A
    4% (1)
  • B
    4% (1)
  • C
    4% (1)
  • D
    89% (24)

Explanation

A list is a data structure in Python that can store multiple values of different types in a sequential order. A list is created by enclosing the values in square brackets [ ] and separating them by commas. A list can also contain other lists as its elements, creating a nested or multidimensional list. The output of the print (var) statement shows that var is a list that contains two elements, each of which is another list with two key-value pairs. The key-value pairs are enclosed in curly braces { }, which indicate that they are dictionaries, another data structure in Python that maps

Topics

#Python#Data structures#Lists#Dictionaries

Community Discussion

No community discussion yet for this question.

Full PT0-002 Practice