Primitive & Abstract
Data Structures in
Python
Structure Smarter, Code Better
Dr. Rohit Saluja (IIT Mandi)
- What we learned:
- Classes
- Objects and Methods
- Clear distinctions between
- Instance
- Class
- Static methods
- Importance of built-in functions for common tasks.
- Today’s Topic: Primitive & Abstract Data Structures
Quick Recap : Classes and Inbuilt Functions
What will the output be?
Answer in zoom chat:
True or False?
Questions
- A static method can access instance variables directly.
(True/False)
- You must create an object to call a class method. (True/False)
- self is a required parameter for all methods in a class.
(True/False)
- A class can have both instance and static methods.
(True/False)
What will the output be?
Answer in zoom chat:
Lecture Overview
- Introduction to Data Structures
- Primitive Data Structures
- Abstract Data Structures
- Use Cases
What are Data Structures?
Data structures are ways to store and organize data to make it
efficient to access and modify.
Types of Data Structures in Python
Two Main Categories:
- Primitive Data Structures (Already learnt):
- Int, Float, Str, Bool
- Abstract Data Structures:
- List, Dictionary, Sets, Tuples
Abstract Data Structures in Python
- Collections in Python that help organize multiple pieces of data efficiently.
Example
- List: Ordered, mutable collection.
- Tuple: Ordered, immutable collection.
- Dictionary: Key-value pairs for fast lookups.
- Set: Unordered, unique collection.
Lists in Python
- Mutable, ordered collection of elements.
Example
- Storing a collection of items where order matters and items may need to
be added or removed.
In Class Activity
Question
- What will be the output of the following code?
Tuples in Python
- Immutable, ordered collection.
Example
- Useful for storing fixed collections of items, such as coordinates or
configuration values.
In Class Activity
Question
- What will be the output of the following code?
Dictionaries in Python
- Key-value pairs that allow for fast lookup.
Example
- Great for storing data that requires unique identifiers, like user profiles
or inventory items.
In Class Activity
Question
- What will be the output of the following code?
Sets in Python
- Unordered collection of unique items.
Example
- Removing duplicates, performing set operations like union and
intersection.
In Class Activity
Question
- What will be the output of the following code?
Comparison of Abstract Data Structures
Takeaways
- What we learned:
- Primitive Data Types:
- Int, float
- str, bool
- Abstract Data Structures:
- List, Tuples
- Dictionary, Sets
- Choosing the Right Structure:
- Understand the problem requirements to select
the best structure in Python.
- Next : Adv. List, String and Brute force approach
Thank You

Abstract and Primitive Data structures in python

  • 1.
    Primitive & Abstract DataStructures in Python Structure Smarter, Code Better Dr. Rohit Saluja (IIT Mandi)
  • 2.
    - What welearned: - Classes - Objects and Methods - Clear distinctions between - Instance - Class - Static methods - Importance of built-in functions for common tasks. - Today’s Topic: Primitive & Abstract Data Structures Quick Recap : Classes and Inbuilt Functions
  • 3.
    What will theoutput be? Answer in zoom chat:
  • 4.
    True or False? Questions -A static method can access instance variables directly. (True/False) - You must create an object to call a class method. (True/False) - self is a required parameter for all methods in a class. (True/False) - A class can have both instance and static methods. (True/False)
  • 5.
    What will theoutput be? Answer in zoom chat:
  • 6.
    Lecture Overview - Introductionto Data Structures - Primitive Data Structures - Abstract Data Structures - Use Cases
  • 7.
    What are DataStructures? Data structures are ways to store and organize data to make it efficient to access and modify.
  • 8.
    Types of DataStructures in Python Two Main Categories: - Primitive Data Structures (Already learnt): - Int, Float, Str, Bool - Abstract Data Structures: - List, Dictionary, Sets, Tuples
  • 9.
    Abstract Data Structuresin Python - Collections in Python that help organize multiple pieces of data efficiently. Example - List: Ordered, mutable collection. - Tuple: Ordered, immutable collection. - Dictionary: Key-value pairs for fast lookups. - Set: Unordered, unique collection.
  • 10.
    Lists in Python -Mutable, ordered collection of elements. Example - Storing a collection of items where order matters and items may need to be added or removed.
  • 11.
    In Class Activity Question -What will be the output of the following code?
  • 12.
    Tuples in Python -Immutable, ordered collection. Example - Useful for storing fixed collections of items, such as coordinates or configuration values.
  • 13.
    In Class Activity Question -What will be the output of the following code?
  • 14.
    Dictionaries in Python -Key-value pairs that allow for fast lookup. Example - Great for storing data that requires unique identifiers, like user profiles or inventory items.
  • 15.
    In Class Activity Question -What will be the output of the following code?
  • 16.
    Sets in Python -Unordered collection of unique items. Example - Removing duplicates, performing set operations like union and intersection.
  • 17.
    In Class Activity Question -What will be the output of the following code?
  • 18.
    Comparison of AbstractData Structures
  • 19.
    Takeaways - What welearned: - Primitive Data Types: - Int, float - str, bool - Abstract Data Structures: - List, Tuples - Dictionary, Sets - Choosing the Right Structure: - Understand the problem requirements to select the best structure in Python. - Next : Adv. List, String and Brute force approach
  • 20.

Editor's Notes

  • #3 Static method called Instance method called Static method called
  • #4 False, False, False, True
  • #5 0 1 2
  • #11 [1, 2, 3, 4, 5] and [1, 2, 3, 4, 5]
  • #13 (1, 2, 3, 4, 5, 6, 4, 5, 6)
  • #15 {'a': 3, 'b': 2}
  • #17 {1, 2, 3, 4}