TGViewer
Channel Public Channel
Python Learning

Python Learning

@python_bds

Python learning resources

Beginner to advanced Python guides, cheatsheets, books and projects.

For data science, backend and automation.
Join πŸ‘‰ https://rebrand.ly/bigdatachannels

DMCA: @disclosure_bds
Contact: @mldatascientist
Subscribers
5.74K
Photos
582
Videos
2
Links
130

Showing posts older than #1272 Β· Back to latest

Older Posts 20 shown
Post #1271 671
🧠 Think Like Python

Suppose you want to know if a username exists.

πŸ”» Many beginners write:
found = False

for user in users:
if user == "Alex":
found = True
break


🟒 Python gives you a simpler solution.

found = "Alex" in users

Less code. More readable. Usually faster to understand.

Whenever Python has a built-in way to express an idea, prefer it.
  • ❀ 3
Post #1268 731
πŸ” 10 Useful String Methods in Python

1. split() β†’ Break text into pieces.
2. join() β†’ Combine multiple strings.
3. replace() β†’ Replace part of a string.
4. strip() β†’ Remove extra spaces.
5. startswith() β†’ Check prefixes.
6. endswith() β†’ Check suffixes.
7. find() β†’ Locate text.
8. count() β†’ Count occurrences.
9. upper() / lower() β†’ Change case.
10. capitalize() β†’ Capitalize the first letter.

These methods appear in almost every real-world Python project.
  • ❀ 5
Post #1267 726
Think Python.pdf899.8 KB
One of our members asked for a Python Book

This book, Think Python, is an introduction to Python programming for beginners.

It starts with basic concepts of programming; it is carefully designed to define all terms when they are first used and to develop each new concept in a logical progression.
  • πŸ”₯ 3
Post #1266 733
πŸš€ Python Time Complexity Cheat Sheet

βœ… List
β€’ Access by index β†’ O(1)
β€’ Append β†’ O(1)
β€’ Insert at beginning β†’ O(n)
β€’ Delete from middle β†’ O(n)
β€’ Search (in) β†’ O(n)
Best for: Ordered collections where fast indexing matters.

βœ… Dictionary (dict)
β€’ Lookup β†’ O(1)
β€’ Insert β†’ O(1)
β€’ Update β†’ O(1)
β€’ Delete β†’ O(1)
Best for: Fast lookups using keys.

βœ… Set
β€’ Add β†’ O(1)
β€’ Remove β†’ O(1)
β€’ Membership test β†’ O(1)
Best for: Removing duplicates and fast membership checks.

βœ… Tuple
β€’ Access β†’ O(1)
β€’ Search β†’ O(n)
Best for: Read-only collections that shouldn't change.
  • ❀ 3
Post #1265 678
πŸ“– Reading Python Error Messages

Suppose you see this.
TypeError: 'NoneType' object is not iterable

Instead of guessing, break it down.

TypeError β†’ You're performing an operation on an incompatible type.
NoneType β†’ The value is None.
not iterable β†’ Python expected something it could loop over, like a list or tuple.

A common cause:
def get_users():
print("Loading users...")

for user in get_users():
print(user)


get_users()
doesn't return anything, so it returns None by default. Python can't loop over None.

When you see this error, ask yourself:
"Which variable was supposed to contain a list but ended up being None?"
  • ❀ 4
Post #1264 636
🐍 15 Python Built-in Functions Every Developer Should Know

You don't always need another library.
Python already ships with powerful built-in functions that can make your code cleaner, shorter, and faster.

1. enumerate() - Loop through items while automatically keeping track of their index.

2. zip() - Combine multiple lists together element by element.

3. map() - Apply the same function to every item in an
iterable.

4. filter() - Keep only the elements that satisfy a condition.

5. sorted() - Return a new sorted list without changing the original.

6. any() - Returns True if at least one item is truthy.

7. all() - Returns True only if every item is truthy.

8. sum() - Quickly calculate the total of numeric values.

9. min() / max() - Find the smallest or largest value instantly.

10. len() - Count the number of items in any iterable.

11. set() - Remove duplicate values while creating a collection of unique items.

12. isinstance() - Check whether an object belongs to a specific type.
13. range() - Generate sequences of numbers efficiently.

14. reversed() - Iterate over data in reverse order without modifying it.

15. help() - Open the built-in documentation for almost any Python object.

Learning these built-ins will make your code look much more "Pythonic" and save you from writing unnecessary loops.
  • ❀ 4
Post #1262 635
A Japanese AI company called Preferred Networks has a mature open-source library for NumPy/SciPy calculations on GPUs.

It's called CuPy πŸš€.

For massive datasets, it is often enough to replace a single line: import cupy as cp
The same array operations can run on CUDA up to 100 times faster.

What it can do:
πŸ›  Highly compatible with existing NumPy and SciPy code
πŸ“ Dramatically reduces the need to rewrite code or learn new syntax
πŸ’» Supports not only NVIDIA CUDA but also AMD ROCm architectures

Keep in mind:
β†’ Only faster for massive arrays; small datasets will run slower due to CPU-to-GPU data transfer lag
β†’ Strictly bound by your physical GPU VRAM limits (can cause out-of-memory errors).
β†’ Covers most major math functions, but does not replicate 100% of NumPy/SciPy modules.

The project is completely open-source and battle-tested since 2015 πŸ“‚: https://github.com/cupy/cupy
  • ❀ 4
Post #1260 772

Forwarded from Free Programming Books

πŸ“˜ Biopython: Tutorial and Cookbook

✍️ Authors: Jeff Chang, Brad Chapman, Iddo Friedberg, Thomas Hamelryck, Michiel de Hoon, Peter Cock, Tiago Antao, Eric Talevich, Bartek WilczyΕ„ski

πŸ”— Read Online

#Python
────────────────────
πŸ‘‰ @free_programming_books_bds πŸ‘ˆ
  • ❀ 4
Post #1259 716
The Unofficial Python Graph Gallery

If you work with data, you already know the pain of making charts look decent in Python. You spend 5 minutes writing the logic to process your data, and then 45 minutes wrestling with matplotlib or seaborn trying to figure out why your labels are overlapping, how to change a specific hex color, or how to remove those ugly default borders.

This repository completely solves that. Instead of just listing libraries, it is a massive, beautifully organized collection of hundreds of data visualization examples.

πŸ”— Link
GitHub GitHub - holtzy/The-Python-Graph-Gallery: A website displaying hundreds of charts made with Python A website displaying hundreds of charts made with Python - holtzy/The-Python-Graph-Gallery
  • ❀ 3
Post #1257 857
Python List Exercises Guide
  • ❀ 4
  • πŸ‘ 3
Post #1256 797
Python Web Scraping

This learning path you’ll learn the core Python technologies and skills you need to build your own web scraper. Web scraping is about downloading structured data from the web and processing selected data.

πŸ‘‰ You should already be comfortable writing Python scripts

πŸ”— Learn Here
Realpython Python Web Scraping (Learning Path) – Real Python Learn Python web scraping with Beautiful Soup, Scrapy, and Selenium to extract and automate data collection from websites.
  • ❀ 3
Post #1255 701
πŸ“¦ The Difference Between a Package and a Module

These terms get mixed up a lot.

πŸ“—A module is a single Python file.
math.py


πŸ“šA package is a folder containing multiple modules.
utils/
helpers.py
parser.py
formatter.py


Think of it like this:
πŸ“– Module = One book
πŸ“š Package = An entire bookshelf
  • πŸ‘ 2
Post #1253 633
Python Lambda Function
  • ❀ 3
Older posts β†’
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook β†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 β†’