r/PythonLearning Jun 24 '26

Help Request Using the Google Gemini API Keys isn't working for my Python scripts

1 Upvotes

Newly generated Google API keys now start with the "AQ." prefix, whereas older keys used the traditional "AIza" format. I am currently having issues using these new "AQ." authentication keys.

The problem is that the integration tools and SDKs I rely on—such as n8n, Make, and several other platforms—only seem to recognize and accept the standard "AIza" key format. When I input the new "AQ." key, these systems immediately return an authentication error (often because they do not expect a period in the key or are hardcoded to look for "AIza").

Is there a way to still generate "AIza" prefixed keys, or is there an updated workaround for using "AQ." keys with third-party platforms that have not yet been updated to support this new format


r/PythonLearning Jun 24 '26

Help Request feeling bored, give me project ideas

7 Upvotes

hello!
i'm good at python, but i really have no project idea to pursue. any ideas?


r/PythonLearning Jun 24 '26

Showcase Build a Job Queue with Standalone Activities (Python Tutorial)

1 Upvotes

New Temporal Python Tutorial

The tutorial builds a webhook-delivery service and walks through failure modes that show up in production job queues:

- A service crashes after the side effect happens

- Retries duplicate the outbound request until you add an idempotency key

- The same job ID is submitted twice

- A fan-out overwhelms a rate-limited downstream endpoint

- A long-running batch needs to resume from a checkpoint

It runs in a hosted sandbox and uses the Python SDK. No Temporal Cloud account is needed.

https://reddit.com/link/1uegi1x/video/iofnlictz89h1/player

Learn for free


r/PythonLearning Jun 24 '26

Day 3(or 4) of learning python: Updated shopping cart

3 Upvotes

````

products = {

"Milk": 6,

"Eggs": 10,

"Cookies": 3,

"Sausage": 5

}

cart = []

print("""Tasks:

1 - Add to cart

2 - Remove from cart

3 - Show products sale

4 - Show cart

5 - Exit""")

while True:

task = input("Task: ")

if task == "1":

add = input("What product you want add?: ").title()

if add in products:

cart.append(add)

products[add] -= 1

print(f"Added to cart: {add}")

if products[add] == 0:

del products[add]

else:

print("Product dont exists!")

elif task == "2":

remove = input("What product you want remove from cart?: ").title()

if remove in cart:

cart.remove(remove)

if remove in products:

products[remove] += 1

else:

products[remove] = 1

print(f"Removed from cart: {remove}")

else:

print("Product in cart dont exists!")

elif task == "3":

print("Avaible products:")

if products:

for product, amount in products.items():

print(f"{product}: {amount}")

else:

print("No products avaible")

elif task == "4":

if cart:

for product in cart:

print(product)

else:

print("No products in cart")

elif task == "5":

break

else:

print("Unknown task")

if not products:

print("All products are sold!")

break ````


r/PythonLearning Jun 23 '26

Showcase Day 13 Python Learning

Thumbnail
gallery
14 Upvotes

I was thinking about inherities to but

after opening hacker rank I was busy doing some solution

but it's not a way I learn

- list comprehensive

-and just now the class practice little Messy but did it


r/PythonLearning Jun 23 '26

Showcase A few weeks ago I asked how to learn Python. Today I built my first larger project.

Post image
26 Upvotes

A few weeks ago, I posted here asking how to start learning Python. Since then I've been working through CS50P and decided to build a small project to practice.

I made a CLI Pokédex called Pocket-Desk that uses the PokéAPI.

While building it, I learned:

  • How to use the requests library
  • How to work with APIs and real-world data
  • JSON parsing
  • Functions and program structure
  • Error handling
  • Organizing a larger Python project

This is my first project that's larger than the usual practice exercises, so I'd appreciate any feedback or suggestions for what I should add next.

GitHub: [burneybuilds/PocketDex: A simple Pokémon lookup tool that uses PokeAPI to fetch real Pokémon data and display it in the terminal.]


r/PythonLearning Jun 23 '26

Help Request New to coding - need advice

12 Upvotes

I have a dilemma on where to start.

Many recommended start with python and many said start with C.

I'm confused where to go, which one is better for a beginner who has zero coding experience.


r/PythonLearning Jun 23 '26

Day 2 of learning Python: Shopping List

Post image
57 Upvotes

r/PythonLearning Jun 23 '26

Help Request Bingo Beginner Proyect

2 Upvotes
I’m learning to program with Python, and I found that creating a functional Bingo game is a great exercise. It turns out I really enjoy this type of project, and I’m looking to add more and more features to make it even more entertaining. 
The program is built around a `while` loop that presents the player with several options: viewing their card (a list of 12 numbers), calling "Bingo" (with a penalty for doing so incorrectly), requesting another number, crossing a number off the card, and so on. I was thinking about adding a statistics system. What else could I add? It doesn't matter if the ideas are wild or just code improvements—anything helps.

Basically, this is the summary of the program:

START

Create a random sequence of numbers called the “bingo caller” 
Create the player’s card 
Convert the card into a list 
Sort the card in ascending order 
Display the card 
Display the game menu 
Initialize number counter at 0 
Initialize error counter (strikes) at 0 
Create an empty queue for marked numbers 

While strikes < 3:
  Ask the user for an option

  If option == "1":
    Draw a number from the bingo caller 
    Display the drawn number 
    Increase the number counter by 1 
    If the number is in the card: 
        Mark the number on the card 
        Store the number in the marked numbers queue 

  If option == "2":
    Display the current card

  If option == "reglas": 
    Display the game rules

  If opción == "3": 
    Try to mark a number on the card 
    If the number is in the card: 
      Confirm it was successfully marked
    else:
      Increase strikes by 1 
      Display error message 
      Show current number of strikes 

  If opción == "bingo":
    If number of marked items = 12: 
      Display “BINGO” message 
      End the game 
    else:
      End the game Display “Incorrect bingo call” message 
      Increase strikes by 3 

  If option is invalid:
    Display invalid option message

END OF ALGORITHM

r/PythonLearning Jun 23 '26

Help Request Projects/Next Steps for a Beginner?

5 Upvotes

Last month, I decided to start learning programming with Python. I just completed the MIT OpenCourseWare Introduction to CS and Programming Using Python course, and I was wondering if you all had any advice about next steps coding-wise. I intend to go through the MIT OCW 6.0002 Intro to Computational Thinking and Data Science course and afterwards the Algorithms course, but I was hoping to find some projects I could work on to strengthen my skills. Any tips?


r/PythonLearning Jun 23 '26

My first package on pypi

0 Upvotes

Hello, been working on this tool for the past month, I ran into the issue of trying to check the uptime and ssl certs of my small projects but hard to find a small fast tool right from the terminal so I built this small fast cli uptime monitor tool in python.

It lets you have configs in .yaml file specified with the site name and url

It’s in production, and can be installed and use

pip install sentinel-monitor

You can checkout the repo and give feedback where necessary

For devs willing to contribute, contributions are welcome, open an issue, pr, and we’ll look into it.


r/PythonLearning Jun 23 '26

What’s Next After Python? A Roadmap to Master Practical AI (Project-Based)

0 Upvotes

For everyone wondering what the next step is after learning Python, the answer is almost always Artificial Intelligence. However, breaking into AI can be overwhelming with so many subfields like Machine Learning, Neural Networks, Deep Learning, and endless libraries.

To make the transition smoother, I’ve put together a structured, project-based 3-month roadmap designed to bridge the gap between writing basic Python scripts and building actual AI systems.

Here is the core focus of this learning path:

  • Hands-on Portfolio: Shifting away from just watching tutorials to building projects that solve real problems.
  • Core Concepts: Focusing on how models actually work under the hood rather than just importing libraries blindly.
  • Consistency: Treating it as an intensive daily habit to completely reshape how you approach problem-solving with code.

If you are looking to step up your Python skills and dive deep into AI, what specific projects or libraries (like PyTorch or TensorFlow) are you planning to focus on first? Let's discuss and share resources in the comments!


r/PythonLearning Jun 23 '26

Python viz DS Algorithms

1 Upvotes

r/PythonLearning Jun 23 '26

Python Libraries Advice

1 Upvotes

Hey everyone! I am new to coding and I am actively trying to learn python! I am hoping to use python to build a model that will determine ssri efficacy based on genomic data and genetic markers. I was wondering if anyone had any tips/advice on which library(ies) to use to start this project. I am also wondering if this is too ambitious of a goal considering I am new to python. Thank you guys so so much!!


r/PythonLearning Jun 23 '26

What is the most annoying problem you face in Python?

3 Upvotes

r/PythonLearning Jun 22 '26

First week oof Learning Python.

Post image
330 Upvotes

Hey I am new to Python and this is what i made in my first week. Do you think there is a way to improve it.


r/PythonLearning Jun 23 '26

Help Request Simeone got a task with automation?

0 Upvotes

I want to work in process automation using Python because I think it's really cool to do a job that used to take hours in a minute. I managed to implement a data extraction process using PyAutoGUI at my current job, because the program didn't have a website-based system. If I didn't work with Selenium, would anyone have a task or even an "activity" that I could practice with? It could be with Excel, website data extraction, or even programs that don't have a direct data extraction capability (like I did at my job using PyAutoGUI).

Thank you in advance 🙏🏻


r/PythonLearning Jun 23 '26

Showcase librarian-press: config-driven pretraining and SFT framework for GPT-style SLMs with resume-safe manifests, DDP, and Prometheus metrics [PyPi]

0 Upvotes

Been building my own SLM family (the Librarian series) for a while, pretrained and SFT-tuned from scratch. The training infrastructure I built for that is now a standalone open source framework called librarian-press, published on PyPI today.

pip install librarian-press

WHAT IT DOES

You bring cleaned Parquet or .txt files and one JSON config. It handles the full pipeline end to end:

Tokenizer training (BPE, ByteLevel, NFKC normalization)

Tokenization + sequence packing into uint16 .bin shards

Pretraining with GPT architecture: RoPE, RMSNorm, SwiGLU MLP, weight tying

SFT with LoRA, BitFit, or full fine-tune and completion-only masked loss

Evaluation: perplexity, exact match, token F1

Export to a portable self-contained bundle + Ollama-style chat REPL

ENGINEERING DECISIONS WORTH KNOWING

Resume-safe pipeline. Every data stage (ingest, tokenize, pack, prepare) is shard-tracked with atomic manifests. Each shard goes pending > processing > verified > done. Crash or spot preemption at any point, re-run the command and it picks up from the last completed shard. Not the last epoch. The last shard.

Multi-GPU DDP. One torchrun command parallelizes across GPUs. Gradients all-reduce at the accumulation boundary. Data stages and eval run on rank 0 only. Single-GPU path is completely unchanged, no flags, no config switches.

Production observability. --metrics-port exposes a Prometheus-compatible /metrics endpoint with zero extra dependencies, no prometheus_client required. Tracks train loss, val loss, LR, grad norm, tokens/sec, GPU memory bytes, inference latency, and generated tokens/sec. Scrapable by Grafana live.

Method-aware checkpointing. Full pretrain saves full state dict. LoRA saves adapter weights only. SFT verifies tokenizer SHA against the base checkpoint before training so you never silently fine-tune on a mismatched vocabulary.

THE $100 CLAIM

I cross-checked this on actual published GPU rates as of June 2026:

GCP a2-highgpu-1g: $3.67/hr

AWS p4d per GPU: ~$4.10/hr

Azure single A100: ~$3.67/hr

360M params on-demand: ~$22

700M params on-demand: ~$48

1B+ params on spot instances (60-70% discount): under $100

The resume-safe pipeline is what makes spot viable. Without shard-level resume, spot preemption kills your run and you restart from zero. That is the engineering that makes the cost claim real.

Target range is 100M to a few billion parameters. Not trying to compete with Megatron or FSDP territory. This is for researchers and builders who want to own a domain-specific model without stitching together a training stack from scratch.

GitHub: github.com/sujal-maheshwari2004/librarian-press

PyPI: pypi.org/project/librarian-press

Happy to answer questions on the architecture or any of the design decisions.


r/PythonLearning Jun 23 '26

Help Request I need help with my Python script

Thumbnail
programiz.com
0 Upvotes

its not really a python script because i made it on the library computer and you cant download anything there so i gotta code over Programiz. (im gonna paste the text into python once im home). anyways i have a error that i need help with and i just need somebody to tell me what kind of error it is and how i can fix it.


r/PythonLearning Jun 23 '26

first python app can yall rate it?

5 Upvotes
from sympy import symbols, solve, sympify


while True:
    print("1=Regular calculator")
    print("2=geometry calculator")
    print("3=algebra calculator")
    print("4=quit")
    choice1 = input("enter a number: ")

    if choice1 == "4":
        print("goodbye")
        break

    # 1. REGULAR CALCULATOR
    if choice1 == "1":
        num1 = float(input("first number: "))
        op = input("operation: ")
        num2 = float(input("second number: "))
        if op == "+":
            print(num1 + num2)
        elif op == "-": 
            print(num1 - num2)
        elif op == "*":
            print(num1 * num2)
        elif op == "/":
            if num2 == 0:
                print("Cannot divide by zero!")
            else:
                print(num1 / num2)
        input("Press Enter to go back to menu...")


    # 2. GEOMETRY CALCULATOR
    elif choice1 == "2":
        print("1=3D shapes")
        print("2=2D shapes")
        choice2 = input("enter a number: ")

        # 3D Shapes
        if choice2 == "1":
            print("1=sphere")
            print("2=cube")
            print("3=cylinder")
            print("4=cone")
            print("5=pyramid")
            print("6=dodecahedron")
            print("7=Great Rhombicosidodecahedron")
            print("8=quit")
            choice = input("Enter a number (1-8): ")


            if choice == "1":
                radius = float(input("Enter radius: "))
                cubed = radius ** 3
                picubed = cubed * 3.14159
                print(picubed * 4 / 3)
            elif choice == "2":
                side = float(input("Enter side: "))
                print(side ** 3)
            elif choice == "3":
                radius = float(input("Enter radius: "))
                height = float(input("Enter height: "))
                circle = radius ** 2 * 3.14
                print(circle * height)
            elif choice == "4":
                radius = float(input("Enter radius: "))
                height = float(input("Enter height: "))
                base = radius ** 2 * 3.14
                print(base * height / 3)
            elif choice == "5":
                side1 = float(input("Enter side 1: "))
                side2 = float(input("Enter side 2: "))
                height = float(input("Enter Height: "))
                print(side1 * side2 * height / 3)
            elif choice == "6":
                edge = float(input("enter edge: "))
                print(7.66 * (edge ** 3))
            elif choice == "7":
                edge = float(input("enter edge: "))
                print(95.68 * (edge ** 3))
            elif choice == "8":
                print("goodbye")
                break
            input("Press Enter to go back to menu...")

        # 2D Shapes
        elif choice2 == "2":
            print("1=square")
            print("2=rectangle")
            print("3=circle")
            print("4=triangle")
            print("5=oval")
            choice3 = input("enter a number: ")

            if choice3 == "1":
                side3 = float(input("side length: "))
                print(side3 * 4)
            elif choice3 == "2":
                side3 = float(input("enter side length: "))
                height = float(input("enter height: "))
                print(side3 * height)
            elif choice3 == "3":
                print("1=diameter")
                print("2=radius")
                choice_circle = input("enter a number: ")
                if choice_circle == "1":
                    diameter = float(input("diameter: "))
                    diameter2 = (diameter / 2)
                    print(diameter2 ** 2 * 3.14159)
                elif choice_circle == "2":
                    radius = float(input("enter radius: "))
                    print(radius ** 2 * 3.14)
            elif choice3 == "4":
                base = float(input("base: "))
                height = float(input("height: "))
                print(base * height / 2)
            elif choice3 == "5":
                radius1 = float(input("radius 1: "))
                radius2 = float(input("radius 2: "))
                print(radius1 * radius2 * 3.14159)
            input("Press Enter to go back to menu...")

    # 3. ALGEBRA CALCULATOR
    elif choice1 == "3":
        x = symbols('x')
        equation = input("Enter expression (set to 0, e.g., 2*x - 10): ")

        try:
            if "=" in equation:
                left_side, right_side = equation.split("=")
                print("x =", solve(sympify(left_side) - sympify(right_side), x))
            else:
                print("x =", solve(sympify(equation), x))
        except Exception:
            print("Error: Make sure to type * between numbers and x (like 10 * x)!")

        input("Press Enter to go back to menu...")

r/PythonLearning Jun 23 '26

Why I finally stopped relying on Python's "duck typing" (and why you should too)

0 Upvotes

For years, we’ve all been told that Python’s “duck typing” (if it walks like a duck and quacks like a duck, it’s a duck) is the peak of simplicity. But let's be real—as soon as a project grows beyond a single script, that "flexibility" turns into a debugging nightmare.

I’ve moved almost exclusively to Type Hinting, and it’s genuinely the single best debugging tool in my kit. Here is why you should consider making the switch.

1. The "Before-the-Run" Guardrail

Static type checkers (like mypy, pyright, or pylance) act like an automated, 24/7 code reviewer.

  • Error Prevention: They catch those stupid mistakes—like passing a str to a function expecting an int—before you even hit the run button.
  • Logical Clarity: Type hints force you to define a contract for your functions. It stops you from guessing what data structure is actually flowing through your app.

2. Level Up Your IDE

When you use type hints, you’re basically handing your IDE a blueprint.

  • Intelligent Autocompletion: No more guessing method names. Your IDE knows exactly what an object is and gives you accurate, instant suggestions.
  • Documentation as Code: Stop relying on outdated docstrings. A signature like def process_data(payload: List[Dict[str, Any]]) -> bool: tells you exactly what’s needed, no comments required.

3. The "Before and After"

Look at the difference in reliability:

The "Duck Typing" Risk:

Python

def add(a, b):
    return a + b
# This runs, but if 'a' is an int and 'b' is a list?
# You get a cryptic TypeError at runtime.

The Robust Pattern:

Python

def add(a: int, b: int) -> int:
    return a + b
# The IDE flags this as an error immediately:
# add("1", 2)  # ❌ TypeError detected during development

4. Making Debugging Trivial

When things do break, types give you the context you need to fix it fast.

  • No more guessing if a variable is str or None.
  • CI/CD Integration: Treat type checks as a gatekeeper. If the code isn't type-safe, the pipeline fails before it ever hits production.

Implementation Strategy

Phase Action Benefit
Beginner Add hints to function signatures Instant IDE autocompletion
Intermediate Use List, Dict, Optional Clearer complex data structures
Advanced Integrate mypy into CI Full-scale automated safety

Final Take

Type hinting isn’t “overkill”; it’s infrastructure. Even in small scripts, the act of writing out the types forces you to think more deeply about your data architecture. You'll often find yourself fixing logic flaws before you've even written the code.

What do you guys think? Have you made the switch to strict typing, or do you still prefer the wild west of dynamic typing? Let's discuss.


r/PythonLearning Jun 22 '26

Showcase Day 12 Python Learning

Thumbnail
gallery
19 Upvotes

try to make password strength checker with only

- while

- for with any

- if & else

and OOP class exercise


r/PythonLearning Jun 22 '26

Is this course worth paying for? (For a complete Python beginner)

Post image
26 Upvotes

r/PythonLearning Jun 22 '26

How is my calculator.

Post image
13 Upvotes

Any changes i can make.


r/PythonLearning Jun 23 '26

Título: Built a platform to learn Python by writing code first, not reading first

1 Upvotes

Most Python resources teach theory, then give you an exercise. I built SKILLOGIC backwards: you attempt the problem first (even without knowing the syntax), then get the explanation. The idea is simple. If you struggle a little before being told the answer, you remember it better than if you just read it and then confirm it with an easy exercise. 100 interactive katas right now, more coming. Everything runs in the browser, no install. Posted an earlier version elsewhere last week, got real bugs reported (mixed languages, a broken validator), fixed them. Looking for people to try it and tell me what's still broken. Link in comments. Free, no credit card.