PCEP Python Collections Fundamentals Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Thames
T
Thames
Community Contributor
Quizzes Created: 11982 | Total Attempts: 187,298
| Attempts: 20 | Questions: 20 | Updated: Aug 16, 2026
Please wait...
Question 1 / 21
🏆 Rank #-- ▾
0 %
0/100
Score 0/100

1. What is the output of `len({'a': 1, 'b': 2, 'c': 3})`?

Explanation

In Python, `len()` returns the number of key-value pairs in a dictionary. This dictionary contains three pairs—`'a': 1`, `'b': 2`, and `'c': 3`—so the result is `3`.

Submit
Please wait...
About This Quiz
PCEP Python Collections Fundamentals Quiz - Quiz

This quiz evaluates your understanding of Python collections\u2014lists, tuples, dictionaries, and sets. Master the core data structures used in PCEP certification, including creation, manipulation, and iteration. Test your knowledge of collection methods, indexing, and practical application in real-world Python programs.

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. Tuples in Python are ____.

Explanation

Tuples in Python are immutable, meaning their elements cannot be changed, added, or removed after the tuple is created. If you need to modify the data, create a new tuple or use a mutable collection such as a list.

Submit

3. Which method removes and returns the last element from a list?

Explanation

`pop()` removes and returns the last element of a list when called without an index. By contrast, `remove()` deletes a specified value, and `clear()` empties the list.

Submit

4. What does `my_dict = {'a': 1, 'b': 2}; my_dict['c'] = 3` result in?

Explanation

Assigning `3` to `my_dict['c']` adds a new key-value pair because `'c'` is not already in the dictionary. The existing entries remain unchanged.

Submit

5. Which statement is true about list comprehensions?

Explanation

List comprehensions offer a compact, readable way to create a new list by transforming or filtering items from an iterable, often replacing a longer `for` loop with a single expression.

Submit

6. Which of the following is an unordered collection with no duplicates?

Explanation

A set stores distinct elements, so adding the same value more than once does not create duplicates. Its elements have no guaranteed order. Lists and tuples preserve order and can contain duplicates, while strings are ordered sequences of characters.

Submit

7. What does `my_list[1:3]` return from `my_list = [0, 1, 2, 3, 4]`?

Explanation

Python slicing includes the element at the start index and stops before the end index. Thus, `my_list[1:3]` returns the elements at indexes 1 and 2: `[1, 2]`.

Submit

8. Which collection type uses key-value pairs?

Explanation

A dictionary stores data as key-value pairs, where each unique key maps to a corresponding value. This makes it easy to retrieve a value using its key. Lists and tuples store ordered items, while sets store unique items without key-value mappings.

Submit

9. The `sorted()` function returns a new ____ containing sorted elements.

Explanation

`sorted()` takes an iterable, orders its elements, and returns them in a new list. It does not modify the original iterable.

Submit

10. Which method removes all elements from a list?

Explanation

`clear()` removes every element from a list, leaving it empty. By contrast, `remove()` deletes a specified value, and `pop()` removes and returns one element. `delete()` is not a standard list method.

Submit

11. The `list.insert(index, value)` method inserts a value at a specified ____.

Explanation

The `list.insert(index, value)` method places the given value at the specified position in the list. Existing elements at that position and afterward shift one place to the right.

Submit

12. The method `dict.keys()` returns ____ of the dictionary.

Explanation

Calling `dict.keys()` returns a view containing the dictionary’s keys. This lets you inspect or iterate over the keys; the view reflects changes made to the dictionary.

Submit

13. Sets in Python automatically ____ duplicate values.

Explanation

Sets in Python store only unique values, so when duplicate values are added, the set automatically removes them.

Submit

14. Negative indexing in lists starts from ____.

Explanation

Negative indexing in a list counts backward from the end. The index `-1` refers to the last element, `-2` to the second-to-last, and so on. Therefore, negative indexing starts at `-1`.

Submit

15. What is the correct syntax to access the first element of a list named `items`?

Explanation

In most programming languages, lists use zero-based indexing, meaning the first element is at position 0. Therefore, `items[0]` accesses the first element of the list named `items`.

Submit

16. What is the output of `my_list = [1, 2, 3]; my_list.append(4); print(len(my_list))`?

Explanation

`append(4)` adds the value `4` as a new item at the end of `my_list`. The list then contains four elements, so `len(my_list)` returns `4`.

Submit

17. Which collection type in Python is ordered, mutable, and allows duplicate elements?

Explanation

A list preserves the order of its elements, can be changed after creation, and allows the same value to appear more than once.

Submit

18. What does `my_tuple = (1,); print(type(my_tuple))` output?

Explanation

The code is valid Python, not a syntax error. The trailing comma makes `(1,)` a one-element tuple, and the semicolon separates the assignment from the `print` statement. The output is ``.

Submit

19. The `dict.get(key)` method returns None if the key does not exist, rather than raising a ____.

Explanation

In Python, `dict.get(key)` safely checks for a key and returns `None` when it is absent. Unlike `dict[key]`, it does not raise a `KeyError`.

Submit

20. What is the result of `{1, 2, 3} & {2, 3, 4}`?

Explanation

The `&` operator finds the intersection of two sets—the elements they have in common. Both sets contain `2` and `3`, so the result is `{2, 3}`.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (20)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What is the output of `len({'a': 1, 'b': 2, 'c': 3})`?
Tuples in Python are ____.
Which method removes and returns the last element from a list?
What does `my_dict = {'a': 1, 'b': 2}; my_dict['c'] = 3` result in?
Which statement is true about list comprehensions?
Which of the following is an unordered collection with no duplicates?
What does `my_list[1:3]` return from `my_list = [0, 1, 2, 3, 4]`?
Which collection type uses key-value pairs?
The `sorted()` function returns a new ____ containing sorted elements.
Which method removes all elements from a list?
The `list.insert(index, value)` method inserts a value at a specified...
The method `dict.keys()` returns ____ of the dictionary.
Sets in Python automatically ____ duplicate values.
Negative indexing in lists starts from ____.
What is the correct syntax to access the first element of a list named...
What is the output of `my_list = [1, 2, 3]; my_list.append(4);...
Which collection type in Python is ordered, mutable, and allows...
What does `my_tuple = (1,); print(type(my_tuple))` output?
The `dict.get(key)` method returns None if the key does not exist,...
What is the result of `{1, 2, 3} & {2, 3, 4}`?
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!