Skip to content

Latest commit

 

History

History
77 lines (55 loc) · 3.09 KB

File metadata and controls

77 lines (55 loc) · 3.09 KB

🗂️ 03_Dictionaries_Sets

Welcome to the Dictionaries and Sets section! Dictionaries and Sets are powerful Python data structures used for efficient data storage, lookup, and manipulation. In this section, you’ll learn how to work with key-value pairs in dictionaries and unique elements in sets — both essential for real-world programming.


🧭 Folder Structure

03_Dictionaries_Sets/
│
├── 01_dictionary_basics.py
├── 02_dictionary_methods.py
├── 03_set_basics.py
├── 04_set_methods.py
├── 05_operations_on_sets.py
├── practice_scripts/
└── README.md

📘 Overview

You’ll learn:

  • How to create and access dictionaries and sets.
  • The difference between keys and values in dictionaries.
  • Common dictionary methods for adding, updating, or removing data.
  • How sets automatically handle unique elements.
  • Performing mathematical operations like union and intersection with sets.
  • When to use each data structure in real-world coding.

🧩 Files Description

File Name Description
01_dictionary_basics.py Introduces dictionaries, key-value pairs, and basic operations like adding, accessing, and modifying data.
02_dictionary_methods.py Demonstrates methods such as keys(), values(), items(), get(), update(), and pop().
03_set_basics.py Explains what sets are, how to create them, and their property of storing only unique values.
04_set_methods.py Covers common set methods including add(), remove(), discard(), and clear().
05_operations_on_sets.py Explains mathematical operations on sets: union(), intersection(), difference(), and symmetric_difference().
practice_scripts/ A collection of coding exercises to help you apply your knowledge of dictionaries and sets.

🎯 Learning Goals

By the end of this section, you’ll be able to:

  • Use dictionaries to store and organize structured data efficiently.
  • Retrieve, update, and remove dictionary elements effectively.
  • Use sets for managing unique data collections.
  • Apply set operations to filter or compare datasets.
  • Choose between dictionaries and sets depending on your use case.

💡 Practice Ideas

Here are some ideas to strengthen your understanding:

  • Create a dictionary storing student names and grades; print the top scorer.
  • Merge two dictionaries and update common keys.
  • Use a set to remove duplicate words from a text.
  • Find the common, different, and unique items between two sets of numbers.
  • Write a program to check whether two sets are disjoint.

Next Section → 04_Operators