TGViewer
Channel Public Channel
Learn Python Coding

Learn Python Coding

@pythonre

Learn Python through simple, practical examples and real coding ideas. Clear explanations, useful snippets, and hands-on learning for anyone starting or improving their programming skills.

Admin: @HusseinSheikho || @Hussein_Sheikho
Subscribers
40.9K
Photos
710
Videos
37
Links
518

Showing posts older than #8773 · Back to latest

Older Posts 19 shown
Post #8765 1.35K
✨ Sponsorship Opportunities ✨

📖 By sponsoring Real Python you will reach a demographic of Python software engineers dedicated to improving their craft and their professional careers. We offer our clients multiple touchpoints across our platforms, ensuring your message cuts through to our audience.

🏷️ #Python
  • ❤ 1
Post #8763 1.42K
How to create a sinusoidal wave in Python using Bokeh and NumPy 🐍

import numpy as np

from bokeh.layouts import gridplot
from bokeh.plotting import figure, output_file, show

N = 100
x = np.linspace(0, 4 * np.pi, N)
y0 = np.sin(x)

output_file('sinewave.html')

sine = figure(width=500, plot_height=500, title='Sine')
sine.circle(x, y0, size=10, color="navy", alpha=0.5)

p = gridplot([[sine]], toolbar_location=None)

show(p)


👉  @DataScience4
  • ❤ 2
  • 🔥 1
Post #8756 1.42K
  • ❤ 4
  • 🔥 1
Post #8755 1.56K
💀 How to encrypt a PDF with a password using Python

Ready Python script: takes a regular PDF and creates a password-protected copy.

📦 Library installation
pip install PyPDF2


⌨️ Code
from __future__ import annotations
from pathlib import Path
from typing import Union

from PyPDF2 import PdfReader, PdfWriter

PDFPath = Union[str, Path]


def encrypt_pdf(input_path: PDFPath, output_path: PDFPath, password: str) -> Path:
    """
    Encrypts a PDF file with a password and saves it to output_path.
    Returns the path to the encrypted file.
    """
    in_path = Path(input_path)
    out_path = Path(output_path)

    reader = PdfReader(in_path)
    writer = PdfWriter()

    for page in reader.pages:
        writer.add_page(page)

    writer.encrypt(password)

    with out_path.open("wb") as f:
        writer.write(f)

    return out_path


def encrypt_with_suffix(input_path: PDFPath, password: str, suffix: str = "_encrypted") -> Path:
    """
    Creates an encrypted copy next to the original file.
    For example: secret.pdf → secret_encrypted.pdf
    """
    in_path = Path(input_path)
    output_path = in_path.with_name(f"{in_path.stem}{suffix}{in_path.suffix}")
    return encrypt_pdf(in_path, output_path, password)


if __name__ == "__main__":
    pdf_file = "secret.pdf"
    pdf_password = "pythontoday"

    encrypted_path = encrypt_with_suffix(pdf_file, pdf_password)
    print(f"Encrypted file created: {encrypted_path}")


💡 Where it will be useful

🟢send a document to a client with the password via a separate channel;
🟢store important PDFs in encrypted form;
🟢integrate encryption into your service/bot/admin panel.

#python #code #tipsandtricks

https://t.me/DataScience4 🌟
  • ❤ 4
  • 👍 1
  • 👎 1
Post #8753 1.34K
✨ Quiz: Build a Python MCP Client to Test Servers From Your Terminal ✨

📖 Learn how to create a Python MCP client, start an AI-powered chat session, and run it from the command line. Check your understanding.

🏷️ #intermediate #ai #projects
  • ❤ 3
Post #8752 1.29K
✨ autoregressive generation | AI Coding Glossary ✨

📖 A method in which a model produces a sequence one token at a time, with each token conditioned on all previously generated tokens.

🏷️ #Python
Post #8751 1.48K
✨ nearest neighbor | AI Coding Glossary ✨

📖 The data point in a reference set that has the smallest distance to a query point.

🏷️ #Python
Post #8750 1.57K
✨ Google Antigravity | AI Coding Tools ✨

📖 An agent-first IDE where AI agents operate the editor, terminal, and browser and produce verifiable Artifacts of their work.

🏷️ #Python
Post #8749 1.44K
✨ bias | AI Coding Glossary ✨

📖 A systematic deviation from truth or fairness.

🏷️ #Python
  • ❤ 1
Post #8748 1.38K
✨ Pydantic AI | AI Coding Tools ✨

📖 A Python framework for building typed LLM agents leveraging Pydantic.

🏷️ #Python
Post #8744 1.45K
✨ Meet Our Team ✨

📖 Meet Real Python's team of expert Python developers, educators, and 190+ contributors bringing real-world experience to create practical Python education.

🏷️ #Python
  • 🔥 1
Post #8743 1.18K
✨ Topic: Algorithms Tutorials ✨

📖 Learn Python algorithms: sorting, searching, graphs, DP, Big O. Use heapq, bisect, deque, lru_cache, timeit. Study practical tips and FAQs for interviews.

🏷️ #22_resources
  • ❤ 1
Post #8742 1.16K
✨ Topic: Python Standard Library ✨

📖 Practical Python standard library tutorials to master datetime, pathlib, argparse, subprocess, logging, and more. Write faster, cleaner, dependency-free code.

🏷️ #86_resources
  • ❤ 1
Post #8741 1.21K
✨ vector | AI Coding Glossary ✨

📖 An ordered array of numbers that represents a point, magnitude, and direction.

🏷️ #Python
Post #8740 1.45K
✨ evaluation | AI Coding Glossary ✨

📖 The process of measuring how well an AI system or model meets its objectives.

🏷️ #Python
  • ❤ 1
Post #8739 1.49K
✨ How to Use Google's Gemini CLI for AI Code Assistance ✨

📖 Learn how to use Gemini CLI to bring Google's AI-powered coding assistance directly into your terminal to help you analyze and fix code.

🏷️ #intermediate #ai #tools
Post #8734 1.63K
✨ Quiz: How to Serve a Website With FastAPI Using HTML and Jinja2 ✨

📖 Review how to build dynamic websites with FastAPI and Jinja2, and serve HTML, CSS, and JS with HTMLResponse and StaticFiles.

🏷️ #intermediate #api #front-end #web-dev
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 →