GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com โ€” GitHub - onyxwizard/python-cheatsheet: A comprehensive Python cheatsheet for quick reference and learning

BranchesTags
Open more actions menu

Latest commit

 

History

60 Commits
60 Commits

Folders and files

NameName
Last commit message
Last commit date
Section_10_More_on_function
Section_10_More_on_function
 
 
Section_11_Modules_packages.py
Section_11_Modules_packages.py
 
 
Section_12_files
Section_12_files
 
 
Section_13_Directory
Section_13_Directory
 
 
Section_14_strings
Section_14_strings
 
 
Section_15_pip_package
Section_15_pip_package
 
 
Section_16_Classes_Objects
Section_16_Classes_Objects
 
 
Section_17_Special_methods
Section_17_Special_methods
 
 
Section_18_Property
Section_18_Property
 
 
Section_19_Single_inheritance
Section_19_Single_inheritance
 
 
Section_1_fundamentals
Section_1_fundamentals
 
 
Section_20_Enumeration
Section_20_Enumeration
 
 
Section_21_SOLID_principles
Section_21_SOLID_principles
 
 
Section_22_Multiple_inheritance
Section_22_Multiple_inheritance
 
 
Section_23_Descriptors
Section_23_Descriptors
 
 
Section_24_Meta_programming
Section_24_Meta_programming
 
 
Section_25_Exceptions
Section_25_Exceptions
 
 
Section_26_Multithreading
Section_26_Multithreading
 
 
Section_27_Thread_Synchronization_Techniques
Section_27_Thread_Synchronization_Techniques
 
 
Section_28_Sharing_Data_Between_Threads
Section_28_Sharing_Data_Between_Threads
 
 
Section_29_Multiprocessing
Section_29_Multiprocessing
 
 
Section_2_operators
Section_2_operators
 
 
Section_30_Async_IO
Section_30_Async_IO
 
 
Section_3_controlflow
Section_3_controlflow
 
 
Section_4_functions
Section_4_functions
 
 
Section_5_List
Section_5_List
 
 
Section_6_Dictionary
Section_6_Dictionary
 
 
Section_7_Sets
Section_7_Sets
 
 
Section_8_Exception_Handling
Section_8_Exception_Handling
 
 
Section_9_loops_adv
Section_9_loops_adv
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

๐Ÿ Python Learning Repository

๐Ÿš€ 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.

๐Ÿงฑ Section 1: Fundamentals

๐Ÿ”น 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 and False, 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)

๐Ÿ”„ Section 3: Control Flow

๐Ÿง  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.

โš ๏ธ Section 8: Exception Handling

๐Ÿ›ก๏ธ 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.

๐Ÿ” Section 9: More on Python Loops

๐Ÿ” 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.

๐Ÿงฐ Section 10: More on Python Functions

๐Ÿ”ง 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.

๐Ÿ“ Section 11: Modules & Packages

๐Ÿงฑ 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.

๐Ÿ“„ Section 12: Working with Files

๐Ÿ“‚ 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.

๐Ÿ› ๏ธ Section 15: Third-party Packages, PIP, and Virtual Environments

๐Ÿ“ฆ 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.

๐Ÿงฌ Object-Oriented Programming in Python (OOPS)

๐Ÿง  What Youโ€™ll Learn

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.

๐Ÿงฌ Section 16: Classes and Objects

๐Ÿง‘โ€๐Ÿ’ป 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

๐Ÿงช Section 17: Special Methods (Dunders)

๐Ÿง  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

๐Ÿ”„ Section 19: Inheritance

๐Ÿ‘จโ€๐Ÿ‘ฆ 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

๐Ÿ” Section 20: Multiple Inheritance

๐Ÿงฌ 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

๐Ÿงฉ Section 21: Enumeration

๐Ÿ”ข 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

๐Ÿงฑ Section 22: SOLID Principles

๐Ÿ› ๏ธ Apply SOLID principles for maintainable designs.

  • ๐Ÿ“ฆ Single Responsibility Principle
  • ๐Ÿงฉ Open/Closed Principle
  • ๐Ÿ”„ Liskov Substitution Principle
  • ๐Ÿ“ Interface Segregation Principle
  • ๐Ÿง  Dependency Inversion Principle

๐Ÿงฐ Section 23: Descriptors

๐Ÿ”— 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

๐Ÿงช Section 24: Metaprogramming

๐Ÿ”ฎ 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

๐Ÿงพ Section 25: Exceptions in OOP

โš™๏ธ 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

๐Ÿงฎ Python Concurrency

โฑ๏ธ Build high-performance & responsive Python applications using concurrency techniques.
๐Ÿง  Learn about multithreading, multiprocessing, and asynchronous programming to improve application performance and responsiveness.

๐Ÿ“Œ What Youโ€™ll Learn:

  • Build high-performance & responsive Python applications.
  • Develop multithreaded programs using threading.
  • Run parallel tasks using multiprocessing.
  • Understand single-threaded concurrency via asyncio.

๐Ÿ” Section 26: Multithreading

๐Ÿงต Use threads for I/O-bound tasks.

  • ๐Ÿง  Processes vs Threads โ€“ Understand differences and when to use each.
  • ๐Ÿงต Threading module โ€“ Use threading for concurrent thread execution.
  • ๐Ÿงฑ Extending Thread class โ€“ Customize behavior by subclassing Thread.
  • ๐Ÿ’ฌ Returning values from threads โ€“ Capture results safely.
  • ๐Ÿ“ˆ Multithreading Example โ€“ Scrape stock prices concurrently.
  • ๐ŸŒ™ Daemon threads โ€“ Background threads that donโ€™t block program exit.
  • ๐Ÿงฐ Thread Pools โ€“ Efficiently manage threads using ThreadPoolExecutor.

๐Ÿ”’ Section 27: Thread Synchronization Techniques

๐Ÿ” Avoid race conditions and ensure safe access.

  • ๐Ÿงฑ Lock โ€“ Prevent simultaneous access to shared data.
  • ๐Ÿšฆ Event โ€“ Communicate between threads (e.g., wait/signal patterns).
  • โน๏ธ How to stop a thread โ€“ Safely terminate child threads.
  • ๐Ÿšง Semaphore โ€“ Control number of concurrent threads accessing a resource.

๐Ÿ“ฅ Section 28: Sharing Data Between Threads

๐Ÿ“ฆ Exchange data safely across threads.

  • ๐Ÿงท Thread-safe Queue โ€“ Use queue.Queue for safe inter-thread communication.

๐Ÿš€ Section 29: Multiprocessing

๐Ÿ”Œ Run CPU-bound tasks in parallel using separate processes.

  • ๐Ÿงฒ Multiprocessing module โ€“ Use multiprocessing.Process to spawn new processes.
  • ๐Ÿงฐ Process Pools โ€“ Manage processes efficiently using Pool or ProcessPoolExecutor.

โšก Section 30: Async I/O

โšก Write asynchronous, non-blocking code using coroutines.

  • ๐Ÿง  Understanding Event Loop โ€“ Core of async programming; manages coroutine execution.
  • ๐Ÿงถ async/await โ€“ Define and await coroutines without blocking.
  • ๐Ÿงฉ Creating Tasks โ€“ Schedule coroutines for execution.
  • ๐Ÿšซ Canceling Tasks โ€“ Cancel running tasks using .cancel().
  • โณ Timeout-based Cancellation โ€“ Use asyncio.wait_for() to cancel after timeout.
  • ๐Ÿ• asyncio.wait() โ€“ Run multiple awaitables concurrently.
  • ๐ŸŽฏ Future โ€“ Understand Future objects for eventual results.
  • ๐Ÿงฑ Running multiple tasks concurrently with gather() โ€“ Run tasks concurrently using asyncio.gather().

๐ŸŽ‰ Letโ€™s learn Python together โ€” one concept at a time!


About

A comprehensive Python cheatsheet for quick reference and learning

www.pythontutorial.net/

Topics

modulespippythonpython-advancedpython-controlflowpython-dictionarypython-exception-handlingpython-filespython-functionspython-listpython-oopspython-operatorspython-setpython-stringspython3

Resources

Readme
MIT license
Activity

Stars

57 stars

Watchers

1 watching

Forks

9 forks
Report repository

Contributors

Languages

You are visitor 01402503 โ€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800ร—600. No cookies required.