From 2839c42d5235ae73c6256ab9d58524a08b993cf4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Jan 2026 18:05:44 +0000 Subject: [PATCH 01/26] Bump ccxt from 4.5.30 to 4.5.31 Bumps [ccxt](https://github.com/ccxt/ccxt) from 4.5.30 to 4.5.31. - [Release notes](https://github.com/ccxt/ccxt/releases) - [Commits](https://github.com/ccxt/ccxt/compare/v4.5.30...v4.5.31) --- updated-dependencies: - dependency-name: ccxt dependency-version: 4.5.31 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements_with_versions.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_with_versions.txt b/requirements_with_versions.txt index fefa2acb8b2..5fdcba63e65 100644 --- a/requirements_with_versions.txt +++ b/requirements_with_versions.txt @@ -81,7 +81,7 @@ Unidecode==1.4.0 Ball==0.2.9 pynput==1.8.1 gTTS==2.5.4 -ccxt==4.5.30 +ccxt==4.5.31 fitz==0.0.1.dev2 fastapi==0.128.0 Django==6.0 From 24b8623f70d3e725456d109ae3c9ed7434470c19 Mon Sep 17 00:00:00 2001 From: Harsh Date: Wed, 7 Jan 2026 14:08:14 +0530 Subject: [PATCH 02/26] Update tic tac toe game --- tic-tac-toe.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tic-tac-toe.py diff --git a/tic-tac-toe.py b/tic-tac-toe.py new file mode 100644 index 00000000000..30bc1c68ed8 --- /dev/null +++ b/tic-tac-toe.py @@ -0,0 +1,63 @@ +# Tic Tac Toe Game in Python + +board = [" " for _ in range(9)] + +def print_board(): + print() + print(f" {board[0]} | {board[1]} | {board[2]} ") + print("---|---|---") + print(f" {board[3]} | {board[4]} | {board[5]} ") + print("---|---|---") + print(f" {board[6]} | {board[7]} | {board[8]} ") + print() + +def check_winner(player): + win_conditions = [ + [0,1,2], [3,4,5], [6,7,8], # rows + [0,3,6], [1,4,7], [2,5,8], # columns + [0,4,8], [2,4,6] # diagonals + ] + for condition in win_conditions: + if all(board[i] == player for i in condition): + return True + return False + +def is_draw(): + return " " not in board + +current_player = "X" + +print("Welcome to Tic Tac Toe!") +print("Positions are numbered 1 to 9 as shown below:") +print(""" + 1 | 2 | 3 +---|---|--- + 4 | 5 | 6 +---|---|--- + 7 | 8 | 9 +""") + +while True: + print_board() + try: + move = int(input(f"Player {current_player}, choose position (1-9): ")) - 1 + if board[move] != " ": + print("That position is already taken. Try again.") + continue + except (ValueError, IndexError): + print("Invalid input. Enter a number between 1 and 9.") + continue + + board[move] = current_player + + if check_winner(current_player): + print_board() + print(f"🎉 Player {current_player} wins!") + break + + if is_draw(): + print_board() + print("🤝 It's a draw!") + break + + current_player = "O" if current_player == "X" else "X" From e1a1dfc2f4449e04bc630b0a2a03339306e4f8bf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Jan 2026 17:59:35 +0000 Subject: [PATCH 03/26] Bump urllib3 from 2.6.2 to 2.6.3 Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.6.2 to 2.6.3. - [Release notes](https://github.com/urllib3/urllib3/releases) - [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst) - [Commits](https://github.com/urllib3/urllib3/compare/2.6.2...2.6.3) --- updated-dependencies: - dependency-name: urllib3 dependency-version: 2.6.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements_with_versions.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_with_versions.txt b/requirements_with_versions.txt index 5fdcba63e65..450d05a39f2 100644 --- a/requirements_with_versions.txt +++ b/requirements_with_versions.txt @@ -56,7 +56,7 @@ openpyxl==3.1.2 pytesseract==0.3.13 requests-mock==1.12.1 pyglet==2.1.11 -urllib3==2.6.2 +urllib3==2.6.3 thirdai==0.9.33 google-api-python-client==2.187.0 sound==0.1.0 From 3ac0936e0541bf67d355faa1252f90e661e1b379 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Jan 2026 22:24:01 +0000 Subject: [PATCH 04/26] Bump twilio from 9.9.0 to 9.9.1 Bumps [twilio](https://github.com/twilio/twilio-python) from 9.9.0 to 9.9.1. - [Release notes](https://github.com/twilio/twilio-python/releases) - [Changelog](https://github.com/twilio/twilio-python/blob/main/CHANGES.md) - [Commits](https://github.com/twilio/twilio-python/compare/9.9.0...9.9.1) --- updated-dependencies: - dependency-name: twilio dependency-version: 9.9.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements_with_versions.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_with_versions.txt b/requirements_with_versions.txt index 450d05a39f2..c680c2f3a4b 100644 --- a/requirements_with_versions.txt +++ b/requirements_with_versions.txt @@ -28,7 +28,7 @@ requests==2.32.5 quo==2023.5.1 PyPDF2==3.0.1 pyserial==3.5 -twilio==9.9.0 +twilio==9.9.1 tabula==1.0.5 nltk==3.9.2 Pillow==12.1.0 From 9a57f31e00e3c3e3ecf06e16b401e60f2ea7025b Mon Sep 17 00:00:00 2001 From: Ivan Costa Neto <124218369+StarStrucken@users.noreply.github.com> Date: Tue, 13 Jan 2026 15:42:28 -0700 Subject: [PATCH 05/26] Refactor comments and add author details Updated comments for clarity and added author information. --- photo_timestamp_renamer.py | 199 +++++++++++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 photo_timestamp_renamer.py diff --git a/photo_timestamp_renamer.py b/photo_timestamp_renamer.py new file mode 100644 index 00000000000..ba5df2ed9f1 --- /dev/null +++ b/photo_timestamp_renamer.py @@ -0,0 +1,199 @@ +#!/usr/bin/env python3 +""" +Author: Ivan Costa Neto +Date: 13-01-26 + +Auto-rename photos by timestamp, so you can organize those vacation trip photos!! + +Name format: YYYY-MM-DD_HH-MM-SS[_NN].ext + +Uses EXIF DateTimeOriginal when available (best for JPEG), +otherwise falls back to file modified time, + +i.e. + python rename_photos.py ~/Pictures/Trip --dry-run + python rename_photos.py ~/Pictures/Trip --recursive + python rename_photos.py . --prefix Japan --recursive +""" + +from __future__ import annotations +import argparse +from dataclasses import dataclass +from datetime import datetime +from pathlib import Path +import re +import sys + +SUPPORTED_EXTS = {".jpg", ".jpeg", ".png", ".heic", ".webp", ".tif", ".tiff"} + +# EXIF support is optional (w\ Pillow) +try: + from PIL import Image, ExifTags # type: ignore + PIL_OK = True +except Exception: + PIL_OK = False + + +def is_photo(p: Path) -> bool: + return p.is_file() and p.suffix.lower() in SUPPORTED_EXTS + + +def sanitize_prefix(s: str) -> str: + s = s.strip() + if not s: + return "" + s = re.sub(r"[^\w\-]+", "_", s) + return s[:50] + + +def exif_datetime_original(path: Path) -> datetime | None: + """ + Try to read EXIF DateTimeOriginal/DateTime from image. + Returns None if unavailable. + """ + if not PIL_OK: + return None + try: + img = Image.open(path) + exif = img.getexif() + if not exif: + return None + + # map EXIF tag ids -> names + tag_map = {} + for k, v in ExifTags.TAGS.items(): + tag_map[k] = v + + # common EXIF datetime tags + dto = None + dt = None + for tag_id, value in exif.items(): + name = tag_map.get(tag_id) + if name == "DateTimeOriginal": + dto = value + elif name == "DateTime": + dt = value + + raw = dto or dt + if not raw: + return None + + # EXIF datetime format: "YYYY:MM:DD HH:MM:SS" + raw = str(raw).strip() + return datetime.strptime(raw, "%Y:%m:%d %H:%M:%S") + except Exception: + return None + + +def file_mtime(path: Path) -> datetime: + return datetime.fromtimestamp(path.stat().st_mtime) + + +def unique_name(dest_dir: Path, base: str, ext: str) -> Path: + """ + If base.ext exists, append _01, _02, ... + """ + cand = dest_dir / f"{base}{ext}" + if not cand.exists(): + return cand + i = 1 + while True: + cand = dest_dir / f"{base}_{i:02d}{ext}" + if not cand.exists(): + return cand + i += 1 + + +@dataclass +class Options: + folder: Path + recursive: bool + dry_run: bool + prefix: str + keep_original: bool # if true, don't rename if it already matches our format + + +def already_formatted(name: str) -> bool: + # matches: YYYY-MM-DD_HH-MM-SS or with prefix and/or _NN + pattern = r"^(?:[A-Za-z0-9_]+_)?\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}(?:_\d{2})?$" + return re.match(pattern, Path(name).stem) is not None + + +def gather_photos(folder: Path, recursive: bool) -> list[Path]: + if recursive: + return [p for p in folder.rglob("*") if is_photo(p)] + return [p for p in folder.iterdir() if is_photo(p)] + + +def rename_photos(opts: Options) -> int: + photos = gather_photos(opts.folder, opts.recursive) + photos.sort() + + if not photos: + print("No supported photo files found.") + return 0 + + if opts.prefix: + pref = sanitize_prefix(opts.prefix) + else: + pref = "" + + renamed = 0 + for p in photos: + if opts.keep_original and already_formatted(p.name): + continue + + dt = exif_datetime_original(p) or file_mtime(p) + base = dt.strftime("%Y-%m-%d_%H-%M-%S") + if pref: + base = f"{pref}_{base}" + + dest = unique_name(p.parent, base, p.suffix.lower()) + + if dest.name == p.name: + continue + + if opts.dry_run: + print(f"[DRY] {p.relative_to(opts.folder)} -> {dest.name}") + else: + p.rename(dest) + print(f"[OK ] {p.relative_to(opts.folder)} -> {dest.name}") + renamed += 1 + + if not opts.dry_run: + print(f"\nDone. Renamed {renamed} file(s).") + return renamed + + +def main(argv: list[str]) -> int: + ap = argparse.ArgumentParser(description="Auto-rename photos using EXIF date (or file modified time).") + ap.add_argument("folder", help="Folder containing photos") + ap.add_argument("--recursive", action="store_true", help="Process subfolders too") + ap.add_argument("--dry-run", action="store_true", help="Preview changes without renaming") + ap.add_argument("--prefix", default="", help="Optional prefix (e.g., Japan, RWTH, Trip)") + ap.add_argument("--keep-original", action="store_true", + help="Skip files that already match YYYY-MM-DD_HH-MM-SS naming") + args = ap.parse_args(argv) + + folder = Path(args.folder).expanduser() + if not folder.exists() or not folder.is_dir(): + print(f"Not a directory: {folder}", file=sys.stderr) + return 2 + + if not PIL_OK: + print("[Note] Pillow not installed; EXIF dates won't be read (mtime fallback only).") + print(" Install for best results: pip install pillow") + + opts = Options( + folder=folder, + recursive=args.recursive, + dry_run=args.dry_run, + prefix=args.prefix, + keep_original=args.keep_original, + ) + rename_photos(opts) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main(sys.argv[1:])) From fbb488882201b85162be93bccad3361175471014 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Jan 2026 18:13:13 +0000 Subject: [PATCH 06/26] Bump keras from 3.13.0 to 3.13.1 Bumps [keras](https://github.com/keras-team/keras) from 3.13.0 to 3.13.1. - [Release notes](https://github.com/keras-team/keras/releases) - [Commits](https://github.com/keras-team/keras/compare/v3.13.0...v3.13.1) --- updated-dependencies: - dependency-name: keras dependency-version: 3.13.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- requirements_with_versions.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_with_versions.txt b/requirements_with_versions.txt index c680c2f3a4b..9d19efc12d4 100644 --- a/requirements_with_versions.txt +++ b/requirements_with_versions.txt @@ -41,7 +41,7 @@ tornado==6.5.4 obs==0.0.0 todo==0.1 oauth2client==4.1.3 -keras==3.13.0 +keras==3.13.1 pymongo==4.15.5 playsound==1.3.0 pyttsx3==2.99 From bf005ef1eab31ad0fbf338a2d60bead04ee6370f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Jan 2026 18:13:55 +0000 Subject: [PATCH 07/26] Bump google-api-python-client from 2.187.0 to 2.188.0 Bumps [google-api-python-client](https://github.com/googleapis/google-api-python-client) from 2.187.0 to 2.188.0. - [Release notes](https://github.com/googleapis/google-api-python-client/releases) - [Commits](https://github.com/googleapis/google-api-python-client/compare/v2.187.0...v2.188.0) --- updated-dependencies: - dependency-name: google-api-python-client dependency-version: 2.188.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements_with_versions.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_with_versions.txt b/requirements_with_versions.txt index 9d19efc12d4..5708ce35ef3 100644 --- a/requirements_with_versions.txt +++ b/requirements_with_versions.txt @@ -58,7 +58,7 @@ requests-mock==1.12.1 pyglet==2.1.11 urllib3==2.6.3 thirdai==0.9.33 -google-api-python-client==2.187.0 +google-api-python-client==2.188.0 sound==0.1.0 xlwt==1.3.0 pygame==2.6.1 From 5699e5d48817efe658a6ec8326e6b47ac7f7fb51 Mon Sep 17 00:00:00 2001 From: Nishant Date: Mon, 19 Jan 2026 15:45:29 +0530 Subject: [PATCH 08/26] feat: add image compression script using Pillow --- image_compressor.py | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 image_compressor.py diff --git a/image_compressor.py b/image_compressor.py new file mode 100644 index 00000000000..94d584136f6 --- /dev/null +++ b/image_compressor.py @@ -0,0 +1,51 @@ +import os +import sys +from PIL import Image + +def compress_image(image_path, quality=60): + """ + Compresses an image by reducing its quality. + + Args: + image_path (str): Path to the image file. + quality (int): Quality of the output image (1-100). Default is 60. + """ + try: + # Open the image + with Image.open(image_path) as img: + # Check if file is an image + if img.format not in ["JPEG", "PNG", "JPG"]: + print(f"Skipping {image_path}: Not a standard image format.") + return + + # Create output filename + filename, ext = os.path.splitext(image_path) + output_path = f"{filename}_compressed{ext}" + + # Save with reduced quality + # Optimize=True ensures the encoder does extra work to minimize size + img.save(output_path, quality=quality, optimize=True) + + # Calculate savings + original_size = os.path.getsize(image_path) + new_size = os.path.getsize(output_path) + savings = ((original_size - new_size) / original_size) * 100 + + print(f"[+] Compressed: {output_path}") + print(f" Original: {original_size/1024:.2f} KB") + print(f" New: {new_size/1024:.2f} KB") + print(f" Saved: {savings:.2f}%") + + except Exception as e: + print(f"[-] Error compressing {image_path}: {e}") + +if __name__ == "__main__": + if len(sys.argv) < 2: + print("Usage: python image_compressor.py ") + print("Example: python image_compressor.py photo.jpg") + else: + target_file = sys.argv[1] + if os.path.exists(target_file): + compress_image(target_file) + else: + print(f"Error: File '{target_file}' not found.") \ No newline at end of file From da7df8e2ba45b8e9dcf03bbdf2d44f64c29ca45a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Jan 2026 19:50:53 +0000 Subject: [PATCH 09/26] Bump openai from 2.14.0 to 2.15.0 Bumps [openai](https://github.com/openai/openai-python) from 2.14.0 to 2.15.0. - [Release notes](https://github.com/openai/openai-python/releases) - [Changelog](https://github.com/openai/openai-python/blob/main/CHANGELOG.md) - [Commits](https://github.com/openai/openai-python/compare/v2.14.0...v2.15.0) --- updated-dependencies: - dependency-name: openai dependency-version: 2.15.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements_with_versions.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_with_versions.txt b/requirements_with_versions.txt index 5708ce35ef3..60d5414e0c8 100644 --- a/requirements_with_versions.txt +++ b/requirements_with_versions.txt @@ -49,7 +49,7 @@ auto-mix-prep==0.2.0 lib==4.0.0 pywifi==1.1.12 patterns==0.3 -openai==2.14.0 +openai==2.15.0 background==0.2.1 pydantic==2.12.5 openpyxl==3.1.2 From b67e7da6744b82a9bf2d65c390faacf603ac2164 Mon Sep 17 00:00:00 2001 From: JAVED KHAN AHMED <149111497+JavedKhan93@users.noreply.github.com> Date: Fri, 23 Jan 2026 16:43:17 +0530 Subject: [PATCH 10/26] Add password strength checker function Implement password strength checker with criteria for length, digits, and uppercase letters. --- password_checker_code.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 password_checker_code.py diff --git a/password_checker_code.py b/password_checker_code.py new file mode 100644 index 00000000000..788b928d6b7 --- /dev/null +++ b/password_checker_code.py @@ -0,0 +1,34 @@ +import string + +def check_password_strength(password): + strength = 0 + + # Criteria 1: Length (Must be at least 8 characters) + if len(password) >= 8: + strength += 1 + + # Criteria 2: Must contain Digits (0-9) + has_digit = False + for char in password: + if char.isdigit(): + has_digit = True + break + if has_digit: + strength += 1 + + # Criteria 3: Must contain Uppercase Letters (A-Z) + has_upper = False + for char in password: + if char.isupper(): + has_upper = True + break + if has_upper: + strength += 1 + + return strength + +if __name__ == "__main__": + print("--- Password Strength Checker ---") + # Note: We cannot run input() on the website, but this code is correct. + # If users download it, it will work. + print("Run this script locally to test your password!") From 9beb720e4891cbf76716a472b301ef9301e35539 Mon Sep 17 00:00:00 2001 From: SDiHALF Date: Wed, 28 Jan 2026 01:10:55 +0530 Subject: [PATCH 11/26] Update AREA OF TRIANGLE.py --- AREA OF TRIANGLE.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/AREA OF TRIANGLE.py b/AREA OF TRIANGLE.py index 2aae5b0d645..db9b04a5a78 100644 --- a/AREA OF TRIANGLE.py +++ b/AREA OF TRIANGLE.py @@ -1,17 +1,20 @@ -# Python Program to find the area of triangle -# calculates area of traingle in efficient way!! -a = 5 -b = 6 -c = 7 +def get_valid_side(prompt:str): + while True: + try: + value = float(input(prompt)) + if value <=0: + print("Side must be positive") + continue + return value + except ValueError: + print("Invalid Input") -# Uncomment below to take inputs from the user -# a = float(input('Enter first side: ')) -# b = float(input('Enter second side: ')) -# c = float(input('Enter third side: ')) -# calculate the semi-perimeter -s = (a + b + c) / 2 +a = get_valid_side("Enter side 1: ") +b = get_valid_side("Enter side 2: ") +c = get_valid_side("Enter side 3: ") -# calculate the area -area = (s * (s - a) * (s - b) * (s - c)) ** 0.5 +semi_perimeter = (a + b + c) / 2 + +area = sqrt((s * (s - a) * (s - b) * (s - c))) print("The area of the triangle is %0.2f" % area) From 0c2fcfa4527851634e061590b9d2c448dd2bfd72 Mon Sep 17 00:00:00 2001 From: Derderderr Date: Wed, 11 Feb 2026 23:56:55 +0800 Subject: [PATCH 12/26] Update scrap_file.py Add timeout and streaming for large files, and some other changes --- scrap_file.py | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/scrap_file.py b/scrap_file.py index 7655e792cbe..aab6e2a2e08 100644 --- a/scrap_file.py +++ b/scrap_file.py @@ -6,33 +6,23 @@ import requests -# Function for download file parameter taking as url - +def download(url, filename): + try: + with requests.get(url, stream=True, timeout=10) as response: + response.raise_for_status() # Raises error for 4xx/5xx -def download(url): - f = open( - "file_name.jpg", "wb" - ) # opening file in write binary('wb') mode with file_name.ext ext=extension - f.write(requests.get(url).content) # Writing File Content in file_name.jpg - f.close() - print("Succesfully Downloaded") + with open(filename, "wb") as file: + for chunk in response.iter_content(chunk_size=8192): + if chunk: + file.write(chunk) + print(f"Successfully downloaded: {filename}") -# Function is do same thing as method(download) do,but more strict -def download_2(url): - try: - response = requests.get(url) - except Exception: - print("Failed Download!") - else: - if response.status_code == 200: - with open("file_name.jpg", "wb") as f: - f.write(requests.get(url).content) - print("Succesfully Downloaded") - else: - print("Failed Download!") + except requests.exceptions.RequestException as e: + print(f"Download failed: {e}") -url = "https://avatars0.githubusercontent.com/u/29729380?s=400&v=4" # URL from which we want to download +# Example usage +url = "https://avatars0.githubusercontent.com/u/29729380?s=400&v=4" +download(url, "avatar.jpg") -download(url) From 7f439debca1bb76f2ef359190e090b38ada7ad24 Mon Sep 17 00:00:00 2001 From: Derderderr Date: Thu, 12 Feb 2026 00:02:05 +0800 Subject: [PATCH 13/26] Refractor add welcome and start_game as seperated function --- blackjack.py | 164 +++++++++++++++++++++++++-------------------------- 1 file changed, 81 insertions(+), 83 deletions(-) diff --git a/blackjack.py b/blackjack.py index b2386ff7828..05f25e1f215 100644 --- a/blackjack.py +++ b/blackjack.py @@ -4,104 +4,102 @@ deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11] * 4 -random.shuffle(deck) - -print( - " ********************************************************** " -) -print( - " Welcome to the game Casino - BLACK JACK ! " -) -print( - " ********************************************************** " -) - -d_cards = [] # Initialising dealer's cards -p_cards = [] # Initialising player's cards - -while len(d_cards) != 2: - random.shuffle(deck) - d_cards.append(deck.pop()) - if len(d_cards) == 2: - print("The cards dealer has are X ", d_cards[1]) - -# Displaying the Player's cards -while len(p_cards) != 2: - random.shuffle(deck) - p_cards.append(deck.pop()) - if len(p_cards) == 2: - print("The total of player is ", sum(p_cards)) - print("The cards Player has are ", p_cards) - -if sum(p_cards) > 21: - print("You are BUSTED !\n **************Dealer Wins !!******************\n") - exit() -if sum(d_cards) > 21: +def welcome(): + print( + " ********************************************************** " + ) + print( + " Welcome to the game Casino - BLACK JACK ! " + ) print( - "Dealer is BUSTED !\n ************** You are the Winner !!******************\n" + " ********************************************************** " ) - exit() -if sum(d_cards) == 21: - print("***********************Dealer is the Winner !!******************") - exit() -if sum(d_cards) == 21 and sum(p_cards) == 21: - print("*****************The match is tie !!*************************") - exit() +def start_game(): + random.shuffle(deck) + d_cards = [] + p_cards = [] -def dealer_choice(): - if sum(d_cards) < 17: - while sum(d_cards) < 17: - random.shuffle(deck) - d_cards.append(deck.pop()) + # Dealer initial cards + while len(d_cards) != 2: + random.shuffle(deck) + d_cards.append(deck.pop()) + if len(d_cards) == 2: + print("The cards dealer has are X ", d_cards[1]) + + # Player initial cards + while len(p_cards) != 2: + random.shuffle(deck) + p_cards.append(deck.pop()) + if len(p_cards) == 2: + print("The total of player is ", sum(p_cards)) + print("The cards Player has are ", p_cards) - print("Dealer has total " + str(sum(d_cards)) + "with the cards ", d_cards) + if sum(p_cards) > 21: + print("You are BUSTED !\n **************Dealer Wins !!******************\n") + return - if sum(p_cards) == sum(d_cards): - print("***************The match is tie !!****************") - exit() + if sum(d_cards) > 21: + print( + "Dealer is BUSTED !\n ************** You are the Winner !!******************\n" + ) + return + + if sum(d_cards) == 21 and sum(p_cards) == 21: + print("*****************The match is tie !!*************************") + return if sum(d_cards) == 21: - if sum(p_cards) < 21: - print("***********************Dealer is the Winner !!******************") - elif sum(p_cards) == 21: - print("********************There is tie !!**************************") - else: - print("***********************Dealer is the Winner !!******************") + print("***********************Dealer is the Winner !!******************") + return - elif sum(d_cards) < 21: - if sum(p_cards) < 21 and sum(p_cards) < sum(d_cards): - print("***********************Dealer is the Winner !!******************") - if sum(p_cards) == 21: - print("**********************Player is winner !!**********************") - if sum(p_cards) < 21 and sum(p_cards) > sum(d_cards): - print("**********************Player is winner !!**********************") + def dealer_choice(): + if sum(d_cards) < 17: + while sum(d_cards) < 17: + random.shuffle(deck) + d_cards.append(deck.pop()) + + print("Dealer has total " + str(sum(d_cards)) + " with the cards ", d_cards) - else: - if sum(p_cards) < 21: + if sum(p_cards) == sum(d_cards): + print("***************The match is tie !!****************") + return + + if sum(d_cards) > 21: print("**********************Player is winner !!**********************") - elif sum(p_cards) == 21: + return + + if sum(d_cards) > sum(p_cards): + print("***********************Dealer is the Winner !!******************") + else: print("**********************Player is winner !!**********************") + + # Player turn + while sum(p_cards) < 21: + k = input("Want to hit or stay?\n Press 1 for hit and 0 for stay ") + + if k == "1": + random.shuffle(deck) + p_cards.append(deck.pop()) + print("You have a total of " + str(sum(p_cards)) + " with the cards ", p_cards) + + if sum(p_cards) > 21: + print("*************You are BUSTED !*************\n Dealer Wins !!") + return + + if sum(p_cards) == 21: + print( + "*******************You are the Winner !!*****************************" + ) + return else: - print("***********************Dealer is the Winner !!******************") + dealer_choice() + break -while sum(p_cards) < 21: - k = input("Want to hit or stay?\n Press 1 for hit and 0 for stay ") - if k == 1: - random.shuffle(deck) - p_cards.append(deck.pop()) - print("You have a total of " + str(sum(p_cards)) + " with the cards ", p_cards) - if sum(p_cards) > 21: - print("*************You are BUSTED !*************\n Dealer Wins !!") - if sum(p_cards) == 21: - print( - "*******************You are the Winner !!*****************************" - ) - - else: - dealer_choice() - break +# Run Game +welcome() +start_game() From 131ed9d3c4e8c569bcd2e9689d0a72ff6303b696 Mon Sep 17 00:00:00 2001 From: Derderderr Date: Thu, 12 Feb 2026 00:07:27 +0800 Subject: [PATCH 14/26] Rafractor to much simplier logic and Add check input --- To print series 1,12,123,1234......py | 57 +++++++-------------------- 1 file changed, 15 insertions(+), 42 deletions(-) diff --git a/To print series 1,12,123,1234......py b/To print series 1,12,123,1234......py index cc192eed3eb..d62d34aee3b 100644 --- a/To print series 1,12,123,1234......py +++ b/To print series 1,12,123,1234......py @@ -1,47 +1,20 @@ -# master -def num(a): - # initialising starting number +def print_pattern(rows: int) -> None: + for i in range(1, rows + 1): + print("".join(str(j) for j in range(1, i + 1))) - num = 1 - # outer loop to handle number of rows +def start(): + while True: + try: + n = int(input("Enter number of rows: ")) + if n < 1: + print("Invalid value, enter a positive integer.") + continue + break + except ValueError: + print("Invalid input, please enter a number.") - for i in range(0, a): - # re assigning num + print_pattern(n) - num = 1 - # inner loop to handle number of columns - - # values changing acc. to outer loop - - for k in range(0, i + 1): - # printing number - - print(num, end=" ") - - # incrementing number at each column - - num = num + 1 - - # ending line after each row - - print("\r") - - -# Driver code - -a = 5 - -num(a) -# ======= -# 1-12-123-1234 Pattern up to n lines - -n = int(input("Enter number of rows: ")) - -for i in range(1, n + 1): - for j in range(1, i + 1): - print(j, end="") - print() - -# master +start() From f6731910166a14db1915bec03e36a754293b5f3a Mon Sep 17 00:00:00 2001 From: Derderderr Date: Thu, 12 Feb 2026 23:59:35 +0800 Subject: [PATCH 15/26] Fix --- Multiply.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Multiply.py b/Multiply.py index c8e1b52228f..8d4121cfe56 100644 --- a/Multiply.py +++ b/Multiply.py @@ -1,4 +1,8 @@ def product(a, b): + # Handle negative values + if b < 0: + return -product(a, -b) + if a < b: return product(b, a) elif b != 0: @@ -9,4 +13,4 @@ def product(a, b): a = int(input("Enter first number: ")) b = int(input("Enter second number: ")) -print("Product is: ", product(a, b)) +print("Product is:", product(a, b)) From 5400fba10e06d0b070a74c174c69bd353ea05d21 Mon Sep 17 00:00:00 2001 From: derek-han <68950075+derek-han@users.noreply.github.com> Date: Sun, 15 Feb 2026 11:09:48 +0800 Subject: [PATCH 16/26] Add-Derderderr --- Collatz Sequence/Collaze-Visualize.py | 74 +++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Collatz Sequence/Collaze-Visualize.py diff --git a/Collatz Sequence/Collaze-Visualize.py b/Collatz Sequence/Collaze-Visualize.py new file mode 100644 index 00000000000..8431794e843 --- /dev/null +++ b/Collatz Sequence/Collaze-Visualize.py @@ -0,0 +1,74 @@ +import time +import matplotlib.pyplot as plt + +def collatz_sequence(n): + """Generate the Collatz sequence for n.""" + steps = [n] + while n != 1: + n = n // 2 if n % 2 == 0 else 3 * n + 1 + steps.append(n) + return steps + + +def visualize(sequence, title="Collatz Sequence"): + plt.clf() + plt.plot(sequence, marker='o') + plt.title(title) + plt.xlabel("Step") + plt.ylabel("Value") + plt.yscale("log") # makes visualization MUCH nicer + plt.grid(True) + plt.pause(0.01) + + +def auto_mode(interval): + print("\nAuto mode started.") + print("Press SPACE in the plot window to stop.\n") + + plt.ion() + stop = False + + def on_key(event): + nonlocal stop + if event.key == ' ': + stop = True + + fig = plt.figure() + fig.canvas.mpl_connect("key_press_event", on_key) + + n = 1 + while not stop: + seq = collatz_sequence(n) + visualize(seq, f"Collatz Sequence for n = {n}") + n += 1 + time.sleep(interval) + + plt.ioff() + plt.show() + print("Auto mode stopped.") + + +# --- Main Program --- +try: + num = int(input("Enter a positive integer (or -1 for auto mode): ")) + + if num == -1: + interval = float(input("Enter step interval time (seconds): ")) + auto_mode(interval) + + elif num <= 0: + print("Please enter a positive number greater than 0.") + + else: + seq = collatz_sequence(num) + print("\nCollatz sequence:") + for i, value in enumerate(seq, start=1): + print(f"Step {i}: {value}") + + plt.ion() + visualize(seq, f"Collatz Sequence for n = {num}") + plt.ioff() + plt.show() + +except ValueError: + print("Invalid input! Please enter a valid number.") From 58b3142b5541e03b366e6727c3f3a4cb99f817e3 Mon Sep 17 00:00:00 2001 From: Derderderr Date: Sun, 15 Feb 2026 23:48:33 +0800 Subject: [PATCH 17/26] Update Calculate resistance.py Allow float --- Calculate resistance.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Calculate resistance.py b/Calculate resistance.py index 06dff0b5723..37af01f64dd 100644 --- a/Calculate resistance.py +++ b/Calculate resistance.py @@ -7,8 +7,8 @@ def res(R1, R2): return 0 -Resistance1 = int(input("Enter R1 : ")) -Resistance2 = int(input("Enter R2 : ")) +Resistance1 = float(input("Enter R1 : ")) +Resistance2 = float(input("Enter R2 : ")) option = input("Enter series or parallel :") print("\n") R = res(Resistance1, Resistance2) From bd5e214d9c298b98348e3f9632505cc0efacdce0 Mon Sep 17 00:00:00 2001 From: Aljubina Date: Mon, 16 Feb 2026 10:36:53 +0530 Subject: [PATCH 18/26] renamed the variables --- calci.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/calci.py b/calci.py index 21d9ace5233..e988d10638e 100644 --- a/calci.py +++ b/calci.py @@ -1,4 +1,4 @@ -a = int(input("enter first value")) -b = int(input("enter second value")) -add = a + b +First = int(input("enter first value")) +Second = int(input("enter second value")) +add = First + Second print(add) From ae285de55863f94f70c7b1568ea5cbdb8cff39e7 Mon Sep 17 00:00:00 2001 From: 2007aman Date: Thu, 19 Feb 2026 17:33:59 +0530 Subject: [PATCH 19/26] improved dice class logic and added validation --- dice.py | 64 ++++++++++++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/dice.py b/dice.py index a2e5c12f99b..7f05f277683 100644 --- a/dice.py +++ b/dice.py @@ -1,45 +1,39 @@ -# Script Name : dice.py -# Author : Craig Richards -# Created : 05th February 2017 -# Last Modified : -# Version : 1.0 - -# Modifications : - -# Description : This will randomly select two numbers, -# like throwing dice, you can change the sides of the dice if you wish - import random - -class Die(object): - # A dice has a feature of number about how many sides it has when it's - # established,like 6. - def __init__(self): - self.sides = 6 - - """because a dice contains at least 4 planes. - So use this method to give it a judgement when you need - to change the instance attributes. +class Die: + """ + A class used to represent a multi-sided die. + + Attributes: + sides (int): The number of sides on the die (default is 6). """ - def set_sides(self, sides_change): - if sides_change >= 4: - if sides_change != 6: - print("change sides from 6 to ", sides_change, " !") + def __init__(self, sides=6): + """Initializes the die. Defaults to 6 sides if no value is provided.""" + self.sides = 6 # Internal default + self.set_sides(sides) + + def set_sides(self, num_sides): + """ + Validates and sets the number of sides. + A physical die must have at least 4 sides. + """ + if isinstance(num_sides, int) and num_sides >= 4: + if num_sides != self.sides: + print(f"Changing sides from {self.sides} to {num_sides}!") else: - # added else clause for printing a message that sides set to 6 - print("sides set to 6") - self.sides = sides_change + print(f"Sides already set to {num_sides}.") + self.sides = num_sides else: - print("wrong sides! sides set to 6") + print(f"Invalid input: {num_sides}. Keeping current value: {self.sides}") def roll(self): + """Returns a random integer between 1 and the number of sides.""" return random.randint(1, self.sides) - -d = Die() -d1 = Die() -d.set_sides(4) -d1.set_sides(4) -print(d.roll(), d1.roll()) +# --- Example Usage --- +if __name__ == "__main__": + d1 = Die(4) # Initialize directly with 4 sides + d2 = Die(12) # A Dungeons & Dragons classic + + print(f"Roll Result: D{d1.sides} -> {d1.roll()}, D{d2.sides} -> {d2.roll()}") From cb894596fb20308e2d6ab0ced9d643576db8e77a Mon Sep 17 00:00:00 2001 From: 2007aman Date: Tue, 24 Feb 2026 20:46:35 +0530 Subject: [PATCH 20/26] updated the logic in Armstrong_number.py file --- Armstrong_number.py | 45 +++++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/Armstrong_number.py b/Armstrong_number.py index 9c73522992c..a5b02293aaa 100644 --- a/Armstrong_number.py +++ b/Armstrong_number.py @@ -1,30 +1,19 @@ -""" -In number theory, a narcissistic number (also known as a pluperfect digital invariant (PPDI), an Armstrong number (after Michael F. Armstrong) or a plus perfect number), -in a given number base b, is a number that is the total of its own digits each raised to the power of the number of digits. -Source: https://en.wikipedia.org/wiki/Narcissistic_number -NOTE: -this scripts only works for number in base 10 -""" +def is_armstrong_number(number: str) -> bool: + """Check if a number (as a string) is a narcissistic/Armstrong number.""" + # Logic: Get the exponent (number of digits) + exponent = len(number) + + # Logic: Sum each digit raised to the power in a single line + # This uses a generator, which is memory efficient. + total = sum(int(digit) ** exponent for digit in number) + + # Return the boolean result instead of printing + return total == int(number) +# --- Main execution --- +user_input = input("Enter the number: ") -def is_armstrong_number(number: str): - total: int = 0 - exp: int = len( - number - ) # get the number of digits, this will determinate the exponent - - digits: list[int] = [] - for digit in number: - digits.append(int(digit)) # get the single digits - for x in digits: - total += x**exp # get the power of each digit and sum it to the total - - # display the result - if int(number) == total: - print(number, "is an Armstrong number") - else: - print(number, "is not an Armstrong number") - - -number = input("Enter the number : ") -is_armstrong_number(number) +if is_armstrong_number(user_input): + print(f"{user_input} is an Armstrong number") +else: + print(f"{user_input} is not an Armstrong number") From 3ca6330192b3fa2ca4bbe6aa6c0c190be0351960 Mon Sep 17 00:00:00 2001 From: 2007aman Date: Mon, 9 Mar 2026 05:36:39 +0530 Subject: [PATCH 21/26] added the read file logic in the program in 12 line one and also correct some file names to easy --- 1-file_handle | 1 + 1 file changed, 1 insertion(+) create mode 160000 1-file_handle diff --git a/1-file_handle b/1-file_handle new file mode 160000 index 00000000000..c9283ce68a8 --- /dev/null +++ b/1-file_handle @@ -0,0 +1 @@ +Subproject commit c9283ce68a8ff170e24082e22ed598da549c49ae From d8d6ac84f2f5b3b94a469f12b229677781ec0908 Mon Sep 17 00:00:00 2001 From: "raktimunreal4@gmail.com" Date: Sun, 22 Mar 2026 18:48:30 +0530 Subject: [PATCH 22/26] Create numbername.py --- NumberToNumberName/numbername.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 NumberToNumberName/numbername.py diff --git a/NumberToNumberName/numbername.py b/NumberToNumberName/numbername.py new file mode 100644 index 00000000000..b7fee0ad802 --- /dev/null +++ b/NumberToNumberName/numbername.py @@ -0,0 +1,5 @@ +# A program to write a number in words +# Eg: +# 61893: Sixty One Thousand Eight Hundred Ninety Three + +__import__('os').system('cls') From d155bfe581523685d198052669e72ffd8433e7a7 Mon Sep 17 00:00:00 2001 From: "raktimunreal4@gmail.com" Date: Sun, 22 Mar 2026 18:49:07 +0530 Subject: [PATCH 23/26] Define color variables --- NumberToNumberName/numbername.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NumberToNumberName/numbername.py b/NumberToNumberName/numbername.py index b7fee0ad802..bff7feb2b96 100644 --- a/NumberToNumberName/numbername.py +++ b/NumberToNumberName/numbername.py @@ -3,3 +3,9 @@ # 61893: Sixty One Thousand Eight Hundred Ninety Three __import__('os').system('cls') + + +Y = "\033[38;2;255;200;0m" +W = "\033[38;2;212;212;212;0m" +B = "\033[38;2;108;180;238m;0m" + From 2874164298d72463c02f51edde8696b98156b4ef Mon Sep 17 00:00:00 2001 From: "raktimunreal4@gmail.com" Date: Sun, 22 Mar 2026 18:50:38 +0530 Subject: [PATCH 24/26] Map digits, specific numbers and placevalues --- NumberToNumberName/numbername.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/NumberToNumberName/numbername.py b/NumberToNumberName/numbername.py index bff7feb2b96..7a842de3d5b 100644 --- a/NumberToNumberName/numbername.py +++ b/NumberToNumberName/numbername.py @@ -9,3 +9,29 @@ W = "\033[38;2;212;212;212;0m" B = "\033[38;2;108;180;238m;0m" +numDict = { + 1 : "One", 2 : "Two", 3 : "Three", 4 : "Four", 5 : "Five", + 6 : "Six", 7 : "Seven", 8 : "Eight", 9 : "Nine", 10 : "Ten", + 11 : "Eleven", 12 : "Twelve", 13 : "Thirteen", 14 : "Fourteen", 15 : "Fifteen", + 16 : "Sixteen", 17 : "Seventeen", 18 : "Eighteen", 19 : "Ninteen", 20 : "Twenty", + 30 : "Thirty", 40 : "Forty", 50 : "Fifty", 60 : "Sixty", 70 : "Seventy", + 80 : "Eighty", 90 : "Ninety" +} + +digits = { + "1" : "One", "2" : "Two", "3" : "Three", "4" : "Four", "5" : "Five", + "6" : "Six", "7" : "Seven", "8" : "Eight", "9" : "Nine", "0" : "Zero" +} + +placeValueDict = { + 1 : "", + 2 : "Thousand", + 3 : "Million", + 4 : "Billion", + 5 : "Trillion", + 6 : "Quadrillion", + 7 : "Quintillion", + 8 : "Sextillion", + 9 : "Septilion", + 10 : "Octillion" +} From 4d2780d68bc6ed05889691df44883919026a8d75 Mon Sep 17 00:00:00 2001 From: "raktimunreal4@gmail.com" Date: Sun, 22 Mar 2026 18:53:29 +0530 Subject: [PATCH 25/26] Taking input and validating it --- NumberToNumberName/numbername.py | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/NumberToNumberName/numbername.py b/NumberToNumberName/numbername.py index 7a842de3d5b..5ef47e41b9d 100644 --- a/NumberToNumberName/numbername.py +++ b/NumberToNumberName/numbername.py @@ -35,3 +35,43 @@ 9 : "Septilion", 10 : "Octillion" } + +print("Maximum Input: 999,999,999,999,999,999,999,999,999,999") +print("Minimum Input: -999,999,999,999,999,999,999,999,999,999\n") + +isNegative = False + +while True: + num = input(f"Enter a number: {Y}") + print(f"{W}", end="") + + try: + splittedNum = num.split(".") + + splittedNum[0] = splittedNum[0].replace(" ", "") + if len(splittedNum) == 2: + splittedNum[1] = splittedNum[1].replace(" ", "") + splittedNum[1] = splittedNum[1].rstrip("0") + + if splittedNum[1] == "": + splittedNum.remove("") + + num = int(splittedNum[0]) + + if len(splittedNum) == 1: + placeholder = splittedNum[0] + placeholder = int(placeholder) + else: + placeholder = splittedNum[0] + "." + splittedNum[1] + placeholder = float(placeholder) + + if num >= 1000000000000000000000000000000 or num <= -1000000000000000000000000000000: + print("Input out of range\n") + else: + if num < 0: + isNegative = True + num = num * (-1) + break + except ValueError or EOFError: + print("Invalid Input\n") + From 284115019d25f53ead9cd745e0e1fc0d2dfc2ac6 Mon Sep 17 00:00:00 2001 From: "raktimunreal4@gmail.com" Date: Sun, 22 Mar 2026 18:54:38 +0530 Subject: [PATCH 26/26] Forming and printing the number name --- NumberToNumberName/numbername.py | 64 ++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/NumberToNumberName/numbername.py b/NumberToNumberName/numbername.py index 5ef47e41b9d..8eae393db6b 100644 --- a/NumberToNumberName/numbername.py +++ b/NumberToNumberName/numbername.py @@ -9,6 +9,10 @@ W = "\033[38;2;212;212;212;0m" B = "\033[38;2;108;180;238m;0m" +groupedList = [] +name = "" +nameList = [] + numDict = { 1 : "One", 2 : "Two", 3 : "Three", 4 : "Four", 5 : "Five", 6 : "Six", 7 : "Seven", 8 : "Eight", 9 : "Nine", 10 : "Ten", @@ -75,3 +79,63 @@ except ValueError or EOFError: print("Invalid Input\n") + +if num == 0: + print(f"0 in words is: {Y}Zero{W}") +else: + while num > 0: + groupedList.append(num % 1000) + num //= 1000 + + groupedList.reverse() + + for i in groupedList: + if i != 0: + if i >= 100: + name = name + numDict[int(i/100)] + " Hundred" + i = i % 100 + + if i >= 20: + if name == "": + name = name + numDict[i - (i % 10)] + else: + name = name + " " + numDict[i - (i % 10)] + + i = i % 10 + elif i >= 10: + if name == "": + name = name + numDict[i] + else: + name = name + " " + numDict[i] + + i = i % 10 + + if i != 0: + if name == "": + name = name + numDict[i] + else: + name = name + " " + numDict[i] + + nameList.append(name) + name = "" + else: + nameList.append("") + + for i in range(len(groupedList)): + if nameList[i] != "": + name = name + nameList[i] + " " + placeValueDict[len(groupedList) - i] + " " + + name = name.rstrip() + + if len(splittedNum) == 2 and splittedNum[1] != "": + name = name + f" {B}Point{Y}" + + for i in splittedNum[1]: + name = name + " " + digits[i] + + print(f"{W}", end="") + + if isNegative == False: + print(f"\n{placeholder} in words is: {Y}{name}{W}") + else: + print(f"\n{placeholder} in words is: {Y}Minus {name}{W}")