Python Learning
5.84K subscribers
564 photos
2 videos
100 files
128 links
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
Download Telegram
📊 Essential Python Libraries to build your career in Data Science

1. NumPy:
- Efficient numerical operations and array manipulation.

2. Pandas:
- Data manipulation and analysis with powerful data structures (DataFrame, Series).

3. Matplotlib:
- 2D plotting library for creating visualizations.

4. Seaborn:
- Statistical data visualization built on top of Matplotlib.

5. Scikit-learn:
- Machine learning toolkit for classification, regression, clustering, etc.

6. TensorFlow:
- Open-source machine learning framework for building and deploying ML models.

7. PyTorch:
- Deep learning library, particularly popular for neural network research.

8. SciPy:
- Library for scientific and technical computing.

9. Statsmodels:
- Statistical modeling and econometrics in Python.

10. NLTK (Natural Language Toolkit):
- Tools for working with human language data (text).

11. Gensim:
- Topic modeling and document similarity analysis.

12. Keras:
- High-level neural networks API, running on top of TensorFlow.

13. Plotly:
- Interactive graphing library for making interactive plots.

14. Beautiful Soup:
- Web scraping library for pulling data out of HTML and XML files.

15. OpenCV:
- Library for computer vision tasks.

As a beginner, you can start with Pandas and NumPy for data manipulation and analysis. For data visualization, Matplotlib and Seaborn are great starting points. As you progress, you can explore machine learning with Scikit-learn, TensorFlow, and PyTorch.
5
Forwarded from Free Programming Books
📘Python Data Science Handbook

✍️ Author: Jake VanderPlas

🔗 Read Online

#Python #DataScience
────────────────────
👉 @free_programming_books_bds 👈
🔥 12 Python Tricks That Make Your Code Cleaner

Here are some Python tricks every developer should know.

1. Swap variables without a temporary variable.
a, b = b, a

2. Reverse a list.
nums[::-1]

3. Chain comparisons.
10 < age < 30

4. Multiple assignment.
x = y = z = 0

5. Unpack lists.
first, *middle, last = nums

6. Use underscores for ignored values.
name, _, age = data

7. Format strings with f-strings.
print(f"Hello {name}")

8. Merge dictionaries.
new = dict1 | dict2

9. Remove duplicates.
unique = list(set(nums))

10. Check membership using sets.
if color in {"red", "green", "blue"}:

11. Readable large numbers.
salary = 1_000_000

12. Use with for files.
with open("data.txt") as f:
data = f.read()
2
Python Scenario-Based Interview Question – List Comprehension 🐍

Scenario:
You are given a list of numbers:
numbers = [1, 2, 3, 4, 5, 6]


Question:
Write Python code to create a new list that contains:
1. Only the even numbers from the original list.
2. Each even number multiplied by 2.

Expected Output:


Answer:
even_doubled = [num * 2 for num in numbers if num % 2 == 0]
print(even_doubled)

Explanation:
⦁ The list comprehension iterates over each num in numbers.
⦁ The if num % 2 == 0 condition filters to only even numbers (remainder 0 when divided by 2).
⦁ For those, num * 2 doubles them, building the new list concisely.
4
Five mistakes almost every Python developer makes once


1️⃣ Giving a function a default value that's a list or dictionary. This one is sneaky because it works in your first few tests and then quietly breaks the moment the function gets called more than once because that default gets created a single time, not fresh on every call, and it silently keeps growing in the background.

2️⃣ Creating a bunch of small functions inside a loop that each reference the loop variable
People expect each one to remember its "own" value from when it was created. They don't. They all end up referencing whatever the loop variable became by the time the loop finished, which is almost never what you wanted.

3️⃣ Comparing decimal numbers with a plain equals sign
Computers don't store decimal math with perfect precision, so two numbers that should obviously be equal sometimes aren't, according to the computer. There's a proper "close enough" comparison built for exactly this.

4️⃣ Confusing a quick copy with a real copy
A fast, shallow copy of something with nested lists or dictionaries inside still shares those inner pieces with the original change one, and you accidentally change both. A true independent copy needs a different approach entirely.

5️⃣ Catching every possible error with one generic catch-all
It feels protective in the moment, but it also hides real bugs behind the same wall as the error you actually expected, and you lose the ability to tell them apart.

None of these mean you're bad at this. Almost everyone hits each one exactly once, and then never forgets it.
4
📂 Understanding Python File Modes

When opening a file, the mode determines what you're allowed to do.

Mode Meaning
r 👉 Read only
w 👉 Write (overwrites existing file)
a 👉 Append to the end
x 👉 Create a new file
rb 👉 Read binary files
wb 👉 Write binary files
r+ 👉 Read and write

👉 Using the wrong mode is one of the easiest ways to accidentally erase a file.
🔥4
Python Lambda Function
3
📦 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
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
3
Python List Exercises Guide
4👍2
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
3
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
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
3
Forwarded from Programming Quiz Channel
What is the biggest advantage of using a set instead of a list when checking whether an item exists?
Anonymous Quiz
20%
Sets preserve insertion order better
8%
Sets allow duplicate values
39%
Membership checks are typically much faster
33%
Sets use less memory in every situation
🐍 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.
3