nextRound
TechnologiesCoding ProblemsBookmarksLearning PathsLogin
nextRound
TechnologiesCoding ProblemsBookmarksLearning PathsLogin
nextRound

AI-powered interview preparation platform. Practice with curated questions, mock interviews, and personalized learning paths to crack your dream tech interview.

Quick Links

  • Technologies
  • Mock Interviews
  • Saved Questions
  • Pricing

Company

  • About Us
  • Contact Us

Legal

  • Privacy Policy
  • Terms of Use

© 2026 nextRound. All rights reserved.

Questions
13 of 14
1What are the common built-in data types in Python?
2what is an array
3Since Python 3.7, dictionaries preserve insertion order. How is this guaranteed internally, and what changed from earlier versions?
4What is the difference between str.format(), %-formatting, and f-strings? What are the performance and readability tradeoffs?
5When would you use collections.deque instead of a list, and why?
6Why are strings immutable in Python, and what performance implications does this have for repeated concatenation in a loop?
7What problem does collections.defaultdict solve, and how does it differ from using dict.setdefault?
8How would you efficiently remove duplicates from a list while preserving order?
9How would you design a Least Recently Used (LRU) cache using Python's built-in data structures?
10How does a Python dictionary achieve average O(1) lookup time internally?
11What is the difference between a list and a tuple, and when would you choose one over the other?
12What are the time complexities of common list operations (indexing, append, insert, pop, search)?
13What is the difference between a set and a frozenset?
14How does Python handle Unicode internally, and what is the difference between str and bytes?
PythonPython
Basics
Control Flow and Functions
Data Structures
Comprehensions & Functional Programming
Iterators, Generators & Decorators
Object-Oriented Programming
Exception Handling & Debugging
Concurrency & Parallelism
Performance & Optimization
Testing
Security
Modules, Packaging & Environment
Type Hinting & Modern Python
System Design & Architecture with Python
Best Practices & Design Patterns
Edge Cases & Tricky Interview Questions
13 / 14

What is the difference between a set and a frozenset?

Difficulty: 2/10
Sets, Frozensets, Mutability

Set is mutable; frozenset is immutable and hashable

Both set and frozenset are unordered collections of unique hashable elements and support the same mathematical set operations. The key difference is mutability: set can add and remove elements, so it is not hashable and cannot be a dict key or another set's element. frozenset is immutable after construction, so it is hashable if its elements are hashable and can be used as a dict key or set member.

  1. 1

    Use set when you need to mutate membership during the program.

  2. 2

    Use frozenset when you need an immutable, hashable signature, such as a cache key or permission set.

  3. 3

    Trade-off: frozenset gives safety and hashability; set gives mutation. You can convert with set(fs) or frozenset(s).

  4. 4

    Common mistake: thinking set elements can be any object. Elements must be hashable, so lists and dicts cannot be set members.

  5. 5

    Version note: set and frozenset have been built-in since Python 2.4; their core semantics are stable.

javascript

Scenario Questions

0-2 years experience

  1. 1You need to store unique tags and never change them. Which set type?
  2. 2Can a set contain a list? Why or why not?

2-5 years experience

  1. 1You need a cache key made of several tags. How do you build it?
  2. 2You have a frozenset and need to add one tag temporarily. What do you do?

5-8 years experience

  1. 1You are designing permissions as sets. How do you compare roles and handle inheritance?
  2. 2You need thread-safe read-only set shared across workers. What do you use?

8+ years experience

  1. 1Design a permission system where frozensets are used as immutable cache keys and sets are used for mutations, with auditability.
  2. 2You need to deduplicate millions of frozenset signatures. How do you optimize memory?

Follow-up Questions

  • Can a frozenset contain a list? Why or why not?
  • How would you compute a cache key from a dynamic set of tags?
Sharethis question

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.