ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 322 - PT0-002 discussion

Report
Export

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 ?

A.
An array
Answers
A.
An array
B.
A class
Answers
B.
A class
C.
A dictionary
Answers
C.
A dictionary
D.
A list
Answers
D.
A list
Suggested answer: D

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 keys to values. Therefore, var is a list of dictionaries.

Reference:

*

5. Data Structures --- Python 3.12.1 documentation1, section 5.1. More on Lists

* Python Data Structures - GeeksforGeeks2, section Lists in Python

* Common Python Data Structures (Guide) -- Real Python3, section Lists

asked 02/10/2024
Tristan Zerner
45 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first