101.school
CoursesAbout
Search...⌘K
Generate a course with AI...

    Python

    Receive aemail containing the next unit.
    • Refreshing Python Basics
      • 1.1Python Data Structures
      • 1.2Syntax and Semantics
      • 1.3Conditionals and Loops
    • Introduction to Object-Oriented Programming
      • 2.1Understanding Class and Objects
      • 2.2Design Patterns
      • 2.3Inheritance, Encapsulation, and Polymorphism
    • Python Libraries
      • 3.1Numpy and Matplotlib
      • 3.2Pandas and Seaborn
      • 3.3SciPy
    • Handling Files and Exception
      • 4.1Reading, writing and manipulating files
      • 4.2Introduction to Exceptions
      • 4.3Handling and raising Exceptions
    • Regular Expressions
      • 5.1Introduction to Regular Expressions
      • 5.2Python’s re module
      • 5.3Pattern Matching, Substitution, and Parsing
    • Databases and SQL
      • 6.1Introduction to Databases
      • 6.2Python and SQLite
      • 6.3Presentation of Data
    • Web Scraping with Python
      • 7.1Basics of HTML
      • 7.2Introduction to Beautiful Soup
      • 7.3Web Scraping Case Study
    • Python for Data Analysis
      • 8.1Data cleaning, Transformation, and Analysis using Pandas
      • 8.2Data visualization using Matplotlib and Seaborn
      • 8.3Real-world Data Analysis scenarios
    • Python for Machine Learning
      • 9.1Introduction to Machine Learning with Python
      • 9.2Scikit-learn basics
      • 9.3Supervised and Unsupervised Learning
    • Python for Deep Learning
      • 10.1Introduction to Neural Networks and TensorFlow
      • 10.2Deep Learning with Python
      • 10.3Real-world Deep Learning Applications
    • Advanced Python Concepts
      • 11.1Generators and Iterators
      • 11.2Decorators and Closures
      • 11.3Multithreading and Multiprocessing
    • Advanced Python Concepts
      • 12.1Generators and Iterators
      • 12.2Decorators and Closures
      • 12.3Multithreading and Multiprocessing
    • Python Project
      • 13.1Project Kick-off
      • 13.2Mentor Session
      • 13.3Project Presentation

    Refreshing Python Basics

    Understanding Python Data Structures

    general-purpose programming language

    General-purpose programming language.

    Python data structures are a fundamental aspect of the language that every programmer should be familiar with. They are containers that hold data and provide various ways to store, access, and manipulate that data. In this unit, we will explore the four primary data structures in Python: Lists, Tuples, Sets, and Dictionaries.

    Lists

    A list in Python is an ordered collection of items. Lists are mutable, meaning they can be changed after they are created. They are defined by enclosing a comma-separated sequence of items in square brackets [].

    my_list = [1, 2, 3, 'Python', 5.0]

    You can access elements in a list by their index, modify elements, and delete elements using the del statement. Python also supports slicing, which allows you to access a range of items in a list.

    Tuples

    A tuple is similar to a list in that it is an ordered collection of items. However, tuples are immutable, meaning they cannot be changed after they are created. Tuples are defined by enclosing a comma-separated sequence of items in parentheses ().

    my_tuple = (1, 2, 3, 'Python', 5.0)

    Like lists, you can access elements in a tuple by their index and use slicing. However, you cannot modify or delete elements in a tuple.

    Sets

    A set in Python is an unordered collection of unique items. Sets are mutable, but they cannot contain mutable items. They are defined by enclosing a comma-separated sequence of items in curly braces {}.

    my_set = {1, 2, 3, 'Python', 5.0}

    You can add and remove elements in a set using the add and remove methods, respectively. Python also provides methods to perform standard set operations, such as union, intersection, and difference.

    Dictionaries

    A dictionary in Python is an unordered collection of key-value pairs. Dictionaries are mutable, and each key-value pair is separated by a colon :. They are defined by enclosing a comma-separated sequence of key-value pairs in curly braces {}.

    my_dict = {'name': 'Python', 'version': 3.9, 'type': 'programming language'}

    You can access, modify, and delete elements in a dictionary using their keys. Python also provides methods to get a list of keys, values, or key-value pairs.

    In conclusion, understanding Python data structures and their properties is crucial for effective programming. They provide a way to organize and manipulate data, which is essential in tasks ranging from simple calculations to complex data analysis and machine learning.

    Test me
    Practical exercise
    Further reading

    Hey there, any questions I can help with?

    Sign in to chat
    Next up: Syntax and Semantics