๐ Welcome to the Python Learning Guide!
This repository is your step-by-step roadmap to mastering Python โ from the basics to advanced topics. Whether you're a beginner or looking to sharpen your skills, this guide has got you covered.
๐ Each section builds on the previous one, so you can follow along in order or jump straight into the topic you need.
๐น Learn the basic structure and syntax of Python code.
- ๐ค Variables โ Understand how variables work and how to name them meaningfully.
- ๐ Strings โ Work with text data and perform common string operations.
- ๐งฎ Numbers โ Explore integers and floating-point numbers.
- ๐ฆ Booleans โ Use
True
andFalse
, and understand truthy and falsy values. - ๐ Constants โ Learn how to define constants (by convention).
- ๐ฌ Comments โ Add notes and explanations inside your code.
- ๐ Type conversion โ Convert between types like strings, integers, and floats.
๐ฃ Section 2: Operators
๐ ๏ธ Learn to manipulate data using operators.
- โ Arithmetic operators โ Perform math operations (
+
,-
,*
,/
, etc.) - โ๏ธ Assignment operators โ Assign and update variable values efficiently.
- ๐ Comparison operators โ Compare two values (
==
,!=
,<
,>
, etc.) - ๐ง Logical operators โ Combine conditions (
and
,or
,not
)
๐ง Make decisions and control how your code runs.
- โ ifโฆelse statement โ Run code based on conditions.
- ๐ฏ Ternary operator โ Write compact conditionals.
- ๐ for loop with range() โ Loop for a set number of times.
- โณ while loop โ Repeat while a condition is true.
- ๐ break โ Exit a loop early.
- โญ๏ธ continue โ Skip current iteration and continue looping.
- ๐ช pass โ Placeholder when no action is needed.
๐ฆ Section 4: Functions
๐งฉ Write reusable blocks of code.
- ๐ Python functions โ Define and call functions.
- ๐ฅ Default parameters โ Set default values for arguments.
- ๐ Keyword arguments โ Make function calls more readable.
- ๐ Recursive functions โ Call functions within themselves.
- ๐ง Lambda Expressions โ Create small anonymous functions.
- ๐ Docstrings โ Document your functions clearly.
๐ Section 5: Lists
๐ Work with ordered collections of data.
- ๐ฅ List โ Store and manipulate multiple items.
- ๐ช Tuple โ Immutable lists that stay constant.
- ๐งน Sort a list in place โ Modify a list directly.
- ๐งผ Sorted function โ Get a new sorted list.
- ๐งฉ Slice a List โ Extract parts of a list.
- ๐ฆ Unpack a list โ Assign elements to variables.
- ๐ Iterate over a List โ Loop through items.
- ๐ Find index of an element โ Locate where something is.
- ๐ Map, Filter, Reduce โ Transform and filter list elements.
- ๐ก List comprehensions โ Create lists quickly and cleanly.
๐๏ธ Section 6: Dictionaries
๐๏ธ Use key-value pairs to organize data.
- ๐ Dictionary โ Store data as keys and values.
- ๐งฐ Dictionary comprehension โ Build dictionaries dynamically.
๐ข Section 7: Sets
๐งฎ Work with unique collections of items.
- ๐ Set โ Store unique values.
- ๐งฑ Set comprehension โ Create sets concisely.
- โช Union, Intersection, Difference โ Combine and compare sets.
- โ Subset, Superset, Disjoint sets โ Check relationships between sets.
๐ก๏ธ Handle errors gracefully and keep your programs running.
- ๐ tryโฆexcept โ Catch and handle exceptions.
- ๐งน tryโฆexceptโฆfinally โ Always run cleanup code.
- โ tryโฆexceptโฆelse โ Run code only if no error occurs.
๐ Advanced looping techniques.
- ๐ forโฆelse โ Run code after a loop finishes normally.
- โณ whileโฆelse โ Run code after a while loop ends.
- ๐ doโฆwhile emulation โ Simulate doโฆwhile behavior in Python.
๐ง Master advanced function features.
- ๐ฆ Unpacking tuples โ Assign tuple values to variables.
- ๐ฅ *args Parameters โ Accept any number of positional arguments.
- ๐ *kwargs Parameters โ Accept any number of keyword arguments.
- ๐ง Partial functions โ Fix some arguments for reuse.
- ๐ Type hints โ Improve readability and enable static type checking.
๐งฑ Organize and reuse your code effectively.
- ๐ Modules โ Split code into separate files.
- ๐ Module search path โ Understand how Python finds modules.
- ๐ง name variable โ Control script vs module behavior.
- ๐ Packages โ Organize modules into folders.
- ๐ Private functions โ Hide internal implementation.
๐ Read from and write to files.
- ๐ Read from a text file
- โ๏ธ Write to a text file
- ๐ Create a new text file
- ๐ Check if a file exists
- ๐ Read and write CSV files
- ๐๏ธ Rename and delete files
๐๏ธ Section 13: Working Directories
๐ Interact with your file system.
- ๐ Working with directories
- ๐ List files in a directory
๐ฌ Section 14: Strings
๐ค Advanced string manipulation.
- ๐๏ธ F-strings โ Embed variables directly in strings.
- ๐ง Raw strings โ Avoid escape character issues.
- ๐งฑ Backslash usage โ Handle special characters.
๐ฆ Install and manage external libraries.
- ๐ฆ PyPI & pip โ Install packages from the Python Package Index.
- ๐งบ Virtual Environments โ Isolate project dependencies.
- ๐ป Install pipenv on Windows โ Manage virtual environments easily.
This README provides a structured and beginner-friendly guide to Object-Oriented Programming (OOP) in Python. It's based on your uploaded content and includes:
- ๐น Classes & Objects
- ๐น Instance vs Class Variables
- ๐น
__init__()
method - ๐น Private attributes
- ๐น Static methods
- ๐น Inheritance
- ๐น Special methods (
__str__
,__repr__
, etc.) - ๐น Property management
- ๐น Exceptions in OOP
Each concept is explained with code examples and best practices for writing clean, maintainable object-oriented code.
๐งโ๐ป Build your first class and understand object-oriented programming.
- ๐งฑ Class definition and instance creation
- ๐ฆ Instance vs class variables
- ๐ Private attributes and name mangling
- ๐ ๏ธ Constructor
__init__()
- ๐งฉ Instance methods and static methods
- ๐งพ Method overloading via default and keyword arguments
- ๐ก Best practices for readable OOP
๐ง Customize class behavior using special methods.
- ๐จ๏ธ
__str__
โ user-friendly output - ๐งพ
__repr__
โ unambiguous representation - โ
__eq__
โ define equality logic - ๐ข
__hash__
โ make objects hashable - ๐ซ
__bool__
โ define truthiness - ๐๏ธ
__del__
โ handle object destruction
๐ Section 18: Property
๐๏ธ Control access to internal attributes.
- ๐งฉ Use
property()
to create properties - ๐ Use
@property
decorator - ๐ฅ Getter, setter, and deleter patterns
- ๐ Read-only properties
- ๐ง Best practices for encapsulation
๐จโ๐ฆ Learn inheritance and extend functionality.
- ๐งฌ Single inheritance โ
class Child(Parent)
- ๐ Override methods
- ๐ถ Use
super()
to delegate to parent - ๐งฑ Use
__slots__
for memory efficiency - ๐งป Abstract base classes with
abc.ABC
๐งฌ Understand method resolution order and mixin classes.
- ๐ง Implement multiple inheritance
- ๐งญ MRO โ Pythonโs method lookup strategy
- ๐งฉ Mixin classes for cross-cutting concerns
- ๐ซ Avoid diamond problem with proper design
- ๐งฒ Combine behaviors without deep hierarchies
๐ข Represent fixed sets of constants.
- ๐งฑ Define enums with
enum.Enum
- ๐งท Use
@unique
to prevent duplicate values - ๐งฎ Auto-generate values with
auto()
- ๐ฆ Extend custom enum classes
- ๐ง Use enums instead of hardcoded strings
๐ ๏ธ Apply SOLID principles for maintainable designs.
- ๐ฆ Single Responsibility Principle
- ๐งฉ Open/Closed Principle
- ๐ Liskov Substitution Principle
- ๐ Interface Segregation Principle
- ๐ง Dependency Inversion Principle
๐ Reuse attribute access logic with descriptors.
- ๐ง Descriptor protocol โ
__get__
,__set__
,__delete__
- ๐ฆ Data vs non-data descriptors
- ๐งฉ Reusable validation and computed properties
- ๐งฑ Descriptor examples: type checking, lazy loading
๐ฎ Modify or generate code at runtime.
- ๐งฌ Use
__new__
to control object creation - ๐ฆ Dynamically create classes using
type()
- ๐งฉ Define custom metaclasses
- ๐งฑ Inject behavior via metaclass
- ๐ง Use
dataclass
to auto-generate boilerplate
โ๏ธ Handle errors within object-oriented contexts.
- ๐ง Raise exceptions in methods
- ๐งฉ Create custom exception classes
- ๐ก๏ธ Catch and propagate exceptions
- ๐งน Graceful error recovery in OOP
- ๐ฆ Exception best practices in real applications