r/PythonLearning • • 7h ago

3,000+ people learned SQL with my detective cases (one US college now teaches with it), I built the same thing for Python

15 Upvotes

In June I launched QueryCase, where you learn by working through detective cases instead of watching tutorials. Each case is a short story with a real dataset and a question only your code can answer. It started with SQL, then Excel, and the question I kept getting after that was "can you do this for Python?"

So I built it, and it's now live 😄

Why I think it's worth a look:

  • 3,100+ people have signed up, across 122 countries
  • 19,500+ cases, drills and exams solved on the SQL and Excel courses
  • 530+ people passed the free SQL Rookie exam and earned the certificate
  • An instructor at a US community college used it to teach SQL in a CompTIA Data+ prep lab, then came back with a second class the following term

What's live in Python:

  • Python Foundations (free): the basics from your very first line, ending in an exam and a certificate
  • pandas: 29 cases on working with real data, from filtering and grouping to cleaning messy files and joining tables
  • Statistics with Python: 21 cases, each built around a real decision someone has to make, and each explaining why you'd reach for that method, not just how to type it
  • Short visual lessons that show how an idea works before you write any code
  • A sandbox where you can load your own CSV and practise on it
  • 30 Python interview questions you can read without an account

Machine learning and automation tracks are coming next week! Machine learning takes you from your first decision tree to the kind of fraud model a bank would actually use, and teaches you to test a model honestly so a 90% score means something. Automation is about the jobs that eat an analyst's week, done by code: sorting folders of files, reading and building Excel workbooks, writing reports and emails, and pulling data from APIs and websites.

Your code is real Python running entirely in your browser, so there's nothing to install. Every step is checked as you go, with hints when you're stuck.

It's completely free to start, and you can solve the first case before making an account. I'd really like feedback from people learning Python right now: what's the part that made you want to give up, and does a story help?

querycase.com

Cheers 😄


r/PythonLearning • • 38m ago

pathlib.Path quite slow

1 Upvotes

pathlib.Path appears to run much slower than I expected. The following function deletes .pyc files older than that of the filename passed in as a parameter.

Is there a faster alternative way of doing this?

import time
from pathlib import Path

def stale_pyc_del(path: str) -> None:
    spd_start = time.perf_counter()
    cur_import = Path(path).resolve()
    if Path.is_dir(cur_import):
        cutoff_time = float('+inf')
        pycache_dir = cur_import / "__pycache__"
    else: # file not directory
        cur_file = Path(__file__).resolve()
        cutoff_time = max(cur_file.stat().st_mtime, cur_import.stat().st_mtime)
        pycache_dir = cur_import.parent / "__pycache__"
    if pycache_dir.is_dir():
        for pyc_file in pycache_dir.glob("*.pyc"):
            # print(f"{pyc_file=}, {pyc_file.stat().st_mtime=}, {cutoff_time}")
            if path is None or pyc_file.stat().st_mtime < cutoff_time:
                print(f"deleting: {pyc_file=}")
                pyc_file.unlink()
    spd_end = time.perf_counter()
    print("stale_pyc_del:", os.path.basename(path), "-", f"{((spd_end - spd_start) * 1000):.3f}", "ms")

r/PythonLearning • • 5h ago

Help Request confusion about what's a digital artifact

1 Upvotes

so we have been assigned some projects this semester, where we have to submit a "digital artifact" for any of the project idea we have chosen. I choose a project that is relevant to some calculations and then displaying them using custom dashboards, for visualizing the calculations. but the thing is that we all have to submit our project in the form of a digital artifact. and I'm confused as to what it exactly means. is it a proper app? or a .exe file? a setup? or just something else entirely. I couldn't really understand what ChatGPT told me about either.


r/PythonLearning • • 10h ago

I put an AI on my portfolio that answers questions about me, and made it impossible for it to make things up. Here's how.

0 Upvotes

Recruiters kept asking me the same questions, so I added an "Ask about me" box to my portfolio. The scary part wasn't building it. It was the idea of an AI confidently inventing a job I never had, on my own website.

So the rule was simple: every sentence it says must come from my real résumé facts, and the code checks that before you see the answer.

How it works:

  1. Search runs in your browser. A small embedding model (all-MiniLM-L6-v2) finds the 8 facts most related to your question. No server needed for this step.
  2. Only those 8 facts go to Llama 3.3 70B on Cloudflare Workers AI.
  3. The model must cite a fact for every sentence.
  4. Code (not the model) checks each citation. If a sentence has no valid source, it doesn't get shown.
  5. If nothing matches, it says it doesn't know instead of guessing.

The fun part: personal questions. "Is he married?" or "How old is he?" get a polite refusal, because that's not in the facts and it's nobody's business. People ask those first, every time.

Cost: $0/month. The browser does the search, and Workers AI's free tier covers the rest at portfolio traffic.

What I learned:

- Telling the model "don't hallucinate" does nothing. Checking its output in code does.

- Fewer, better facts beat stuffing the whole résumé into the prompt.

- A refusal that's honest feels more trustworthy than an answer that's smooth.

Happy to answer questions about the citation check or the prompt. And if you've built something similar, how did you handle hallucinations?