Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Python Fundamentals: Build a Strong Foundation for DSA
Highest Rated
Rating: 4.4 out of 5(25 ratings)
492 students

Python Fundamentals: Build a Strong Foundation for DSA

Master the essential Python skills needed for Data Structures and Algorithms in a simplified and beginner-friendly way.
Created bySaurabh Mishra
Last updated 2/2025
Hindi

What you'll learn

  • Master Python Basics – Learn variables, data types, loops, and functions.
  • Understand OOP in Python – Grasp classes, objects, and methods.
  • Work with Data Structures – Learn lists, tuples, dictionaries, and sets.
  • Write Efficient Code – Develop problem-solving skills for DSA preparation.

Course content

8 sections • 46 lectures • 5h 14m total length
  • Importance of DSA2:58

    In this chapter, we will discuss the significance of Data Structures and Algorithms (DSA) in computer science and the tech industry. Understanding why DSA is essential will motivate and guide your learning throughout this course.

  • Basic Data Types and Writing Python Code8:16

    In this chapter, we'll dive into the basic data types in Python—integers, floats, and strings. You'll learn how to write and manipulate these data types with actual Python code.



    Integers (int):

    Whole numbers, positive or negative, without decimals.

    #code

    x = 10

    y = -5

    print(x + y)  # Output: 5



    Floats (float):

    Numbers with decimal points.

    #code

    a = 5.5

    b = 2.3

    print(a * b)  # Output: 12.65



    Booleans (bool):

    Represents True or False.

    #code

    is_valid = True

    print(is_valid)  # Output: True



    Strings (str):

    Sequence of characters.

    #code

    greeting = "Hello"

    name = "Alice"

    print(greeting + " " + name)  # Output: Hello Alice



    Reads a string from user input.


    #code

    # Here + is used for adding strings, we will learn in future videos.

    user_input = input("Enter your name: ")

    print("Hello, " + user_input)



    Converting one data type to another.


    Integer to Float:

    #code

    x = 5

    y = float(x)

    print(y)  # Output: 5.0



    Float to Integer:


    #Code

    a = 3.8

    b = int(a)

    print(b)  # Output: 3



    String to Integer:


    #Code

    s = "123"

    num = int(s)

    print(num)  # Output: 123


    String to Float:


    #Code

    s = "45.67"

    num = float(s)

    print(num)  # Output: 45.67



    Boolean to Integer:


    #Code

    is_valid = True

    num = int(is_valid)

    print(num)  # Output: 1

  • Introduction to Lists & Arrays8:55

    In this chapter, we will explore the concepts of lists and arrays in Python. We'll start by understanding what arrays are and how they differ from lists. Then, we'll delve into common list operations such as append() and insert(), and learn about indexing.



    #code

    # Array

    import array

    arr = array.array('i', [1, 2, 3, 4, 5])

    print(arr)  # Output: array('i', [1, 2, 3, 4, 5])



    - Difference Between Array and List:

    Arrays: Homogeneous data types, require importing the array module.

    Lists: Can store heterogeneous data types, built-in to Python.

    #code

    # List

    my_list = [1, "Hello", 3.4]

    # Array

    import array

    my_array = array.array('i', [1, 2, 3])



    - List Operations - append()

    Adds an element to the end of the list.

    #code

    my_list = [1, 2, 3]

    my_list.append(4)

    print(my_list)  # Output: [1, 2, 3, 4]



    - List Operations - insert()

    Inserts an element at a specified position.

    #code

    my_list = [1, 2, 3]

    my_list.insert(1, 'a')

    print(my_list)  # Output: [1, 'a', 2, 3]



    - Understanding Indexing

    Accessing elements by their index.

    #code

    my_list = ['a', 'b', 'c', 'd']

    print(my_list[1])  # Output: 'b'

    print(my_list[-1])  # Output: 'd'

  • More about List9:00

    In this chapter, we will expand our understanding of lists by exploring advanced operations such as slicing, pop(), remove(), extend(), appending one list to another, and combining lists using the + operator. Additionally, we'll introduce the concept of tuples in Python.



    - List Slicing

    Extracting a portion of a list using slicing.

    #code

    my_list = [1, 2, 3, 4, 5]

    slice1 = my_list[1:3]  # Output: [2, 3]

    slice2 = my_list[:2]   # Output: [1, 2]

    slice3 = my_list[3:]   # Output: [4, 5]

    slice4 = my_list[::2]  # Output: [1, 3, 5]



    - pop():

    Removes and returns an element from a specified position (default is the last item).

    #code

    my_list = [1, 2, 3, 4]

    popped_item = my_list.pop(2)

    print(popped_item)  # Output: 3

    print(my_list)      # Output: [1, 2, 4]



    - remove():

    Removes the first occurrence of a specified value.

    #coding

    my_list = [1, 2, 3, 4, 3]

    my_list.remove(3)

    print(my_list)  # Output: [1, 2, 4, 3]



    - extend():

    Extends the list by appending elements from another list.

    #coding

    list1 = [1, 2, 3]

    list2 = [4, 5]

    list1.extend(list2)

    print(list1)  # Output: [1, 2, 3, 4, 5]



    - Appending a List to Another List:

    Adding a list as a single element to another list.

    #code

    list1 = [1, 2, 3]

    list2 = [4, 5]

    list1.append(list2)

    print(list1)  # Output: [1, 2, 3, [4, 5]]



    Combining Lists with +:

    Combining two lists into a new list.

    #code

    list1 = [1, 2, 3]

    list2 = [4, 5]

    combined_list = list1 + list2

    print(combined_list)  # Output: [1, 2, 3, 4, 5]



    Introduction to Tuples:

    Immutable(can't change) sequences of elements.

    #coding

    my_tuple = (1, 2, 3)

    print(my_tuple)        # Output: (1, 2, 3)

    print(my_tuple[1])     # Output: 2

  • Strings in Python - Concatenation and Slicing4:45

    In this chapter, we will explore the fundamentals of strings in Python. We will cover string concatenation, which is the process of joining two or more strings together, and string slicing, which allows you to extract specific parts of a string.



    Strings are sequences of characters enclosed in quotes.

    #coding

    my_string = "Hello, World!"

    print(my_string)  # Output: Hello, World!


    Joining two or more strings together using the + operator.

    #coding

    str1 = "Hello"

    str2 = "World"

    concatenated_str = str1 + " " + str2

    print(concatenated_str)  # Output: Hello World


    Extracting a portion of a string using slicing.

    #coding

    my_string = "Hello, World!"

    slice1 = my_string[0:5]    # Output: Hello

    slice2 = my_string[7:12]   # Output: World

    slice3 = my_string[::2]    # Output: Hlo ol!

    slice4 = my_string[::-1]   # Output: !dlroW ,olleH


  • Dictionaries in Python6:57

    In this chapter, we will explore dictionaries in Python, a versatile data structure that allows you to store key-value pairs. We will cover essential operations such as updating keys and values, adding new key-value pairs, deleting items, and using various dictionary methods like keys(), values(), and items(). Additionally, we will learn how to check for the presence of keys using the in operator.



    Dictionaries store data as key-value pairs.

    #coding

    my_dict = {"name": "Alice", "age": 25}

    print(my_dict)  # Output: {'name': 'Alice', 'age': 25}



    Modifying an existing key-value pair.

    #coding

    my_dict["age"] = 26

    print(my_dict)  # Output: {'name': 'Alice', 'age': 26}



    Adding a new key-value pair to the dictionary.

    #coding

    my_dict["city"] = "New York"

    print(my_dict)  # Output: {'name': 'Alice', 'age': 26, 'city': 'New York'}




    Removing a key-value pair from the dictionary.

    #coding

    del my_dict["age"]

    print(my_dict)  # Output: {'name': 'Alice', 'city': 'New York'}




    Checking if a key exists in the dictionary.

    #coding

    if "name" in my_dict:

        print("Name is present")  # Output: Name is present




    keys(): Returns a view object of all keys.

    #coding

    keys = my_dict.keys()

    print(keys)  # Output: dict_keys(['name', 'city'])




    values(): Returns a view object of all values.

    #coding

    keys = my_dict.keys()

    print(keys)  # Output: dict_keys(['name', 'city'])




    items(): Returns a view object of all key-value pairs

  • Sets in Python6:39

    In this chapter, we will dive into sets in Python, a powerful data structure that stores unordered and unique elements. We will learn how to initialize an empty set, create a set with initial elements, and use the type() function to identify the data type. We'll explore the key differences between lists and sets, focusing on the unordered nature and uniqueness of elements in sets. Additionally, we will cover how to add and remove elements from a set, handle duplicate elements, and convert sets to lists. Finally, we'll see how to convert a list with repeated elements into a list of unique elements using sets.



    Sets are collections of unordered and unique elements.

    #code

    my_set = {1, 2, 3}

    print(my_set)  # Output: {1, 2, 3}



    Initializing an Empty Set:

    - Using the set() function to create an empty set.

    #code

    empty_set = set()

    print(empty_set)  # Output: set()



    Creating a Set with Initial Elements:

    - Defining a set with some elements at the start.

    #code

    my_set = {1, 2, 3, 4}

    print(my_set)  # Output: {1, 2, 3, 4}



    Using type():

    - Checking the type of a set.

    #code

    my_set = {1, 2, 3}

    print(type(my_set))  # Output: <class 'set'>



    Difference Between List and Set:

    - Lists are ordered and can contain duplicate elements.

    - Sets are unordered and contain unique elements.

    #code

    my_list = [1, 2, 2, 3]

    my_set = {1, 2, 2, 3}

    print(my_list)  # Output: [1, 2, 2, 3]

    print(my_set)   # Output: {1, 2, 3}



    No Order and Unique Elements:

    Sets do not maintain order and automatically remove duplicates.

    #code

    my_set = {3, 1, 2, 3}

    print(my_set)  # Output: {1, 2, 3}



    Adding New Elements:

    Using the add() method to add elements to a set.

    #code

    my_set = {1, 2, 3}

    my_set.add(4)

    print(my_set)  # Output: {1, 2, 3, 4}



    Removing Elements:

    - Using the remove() method to remove elements from a set.

    #code

    my_set = {1, 2, 3}

    my_set.remove(2)

    print(my_set)  # Output: {1, 3}



    Handling Multiple Elements:

    - Adding duplicate elements does not change the set.

    #code

    my_set = {1, 2, 3}

    my_set.add(3)

    print(my_set)  # Output: {1, 2, 3}



    Converting Set to List:

    - Using the list() function to convert a set to a list.

    #code

    my_set = {1, 2, 3}

    my_list = list(my_set)

    print(my_list)  # Output: [1, 2, 3]



    Converting List with Repeated Elements to Unique Elements:

    - Using a set to remove duplicates from a list and then converting back to a list.

    #code

    my_list = [1, 2, 2, 3, 3, 3]

    my_unique_list = list(set(my_list))

    print(my_unique_list)  # Output: [1, 2, 3]

Requirements

  • No prior programming experience needed – Beginner-friendly course.
  • A laptop/PC with Python installed – Works on Windows, macOS, or Linux.
  • Basic math skills – Helpful but not mandatory.
  • Willingness to learn – Enthusiasm for coding and problem-solving.

Description

Are you preparing for Data Structures and Algorithms (DSA) but struggling with Python fundamentals? This course is designed for you!

In Python Fundamentals: Build a Strong Foundation for DSA, you'll learn only the Python concepts that are necessary for DSA. This means no unnecessary theory—just the core Python skills required to solve DSA problems efficiently.


What makes this course unique?

  • Beginner-Friendly - No prior Python experience needed!

  • Straight to the Point - Focuses only on what’s required for DSA.

  • Hands-on Coding - Every concept is explained with real code examples.

  • Problem-Solving Oriented - Learn Python while solving practical coding problems.

By the end of this course, you'll have the confidence to start learning DSA with Python without worrying about missing Python fundamentals!


What You’ll Learn:

  • Python Basics (Variables, Data Types, Operators)

  • Loops and Conditionals (For, While, If-Else)

  • Functions and Recursion

  • Lists, Tuples, and Dictionaries (Essential Data Structures)

  • String Manipulation

  • Object-Oriented Programming (OOP) Basics


Who This Course Is For:

  • Beginners in Python who want to focus only on the DSA-related concepts

  • Students preparing for coding interviews with Python

  • Anyone taking a DSA course and needs a quick Python refresher

  • CS/IT students transitioning from another language to Python


Course Requirements:

  • No prior Python knowledge is needed.

  • A computer with an internet connection.

  • Willingness to learn with hands-on coding exercises.

Who this course is for:

  • Beginners in Programming – Anyone new to coding and wants to learn Python.
  • Aspiring DSA Learners – Those preparing for Data Structures & Algorithms.
  • Students & Professionals – Who need Python for coding interviews or career growth.
  • Self-Learners & Enthusiasts – Anyone interested in building a strong Python foundation.