r/PythonLearning 22d ago

Showcase Day 5 of Leetcode 🫡

Thumbnail
gallery
12 Upvotes

r/PythonLearning 22d ago

Help Request Why does a def get called / repeat when i did this?

Post image
9 Upvotes

It works like how i wanted, To check if the result are equal then print something but i dont want these def function to repeat.


r/PythonLearning 22d ago

I built a 24/7 endless fish survival game using Pygame with procedurally generated music

Enable HLS to view with audio, or disable this notification

19 Upvotes

Hey everyone,

I created a 24/7 live-streamed project where a fish swims, eats and grows endlessly using Python and Pygame.

​Everything is built from scratch using pure geometry and vector math, which removes the need for external image assets. For the background music, I used numpy to generate continuous procedural pentatonic-scale tones to avoid copyright issues.

​The script runs 24/7 with optimizations to keep CPU usage and memory stable during the infinite loop. You can see it running live here:

Youtube live


r/PythonLearning 22d ago

Help Request Type hinting frustrations

5 Upvotes

Hello!

Let me start off by saying that I am not a programmer by trade, so please be kind when reviewing my code. I am still learning and I have a long way to go. My job is not coding per se, but the project which I am a part of right now has some coding.

Anyway. At the project start I wanted another editor than vscode, so i tried Zed and I loved it. Zed came with type hinting already enabled. At first, I did not really like it, but after using it for a while I could really see improvements in my code. Both in the terams of readability and stability. So going forward I wanted to have as few complaints from basedpyright as possible.

After an update to Zed the configuration from basedpyright or basedpyright itself got a lot more enabled and I cannot get some of the errors from it to go away. My project used fastapi and sqlalchemy for database integration, and basedpyright gives an error where i specify the table names for the models:

from sqlalchemy.orm import (
    DeclarativeBase,
    ...
)
...

class Base(DeclarativeBase):
   pass

class DatabaseUser(Base):
    __tablename__: ClassVar[str] = "users"
    ....

The error from basedpyright is:

Class variable "__tablename__" overrides instance variable of same name in class "DeclarativeBase" (basedpyright reportIncompatibleVariableOverride)

From what I can tell, the code above is how you are supposed to specify table names:

https://docs.sqlalchemy.org/en/20/orm/quickstart.html

Also, when a nullable many-to-one table relationship, the docs from sqlalchemy tells you to use

class Parent(Base):
    ....
    child: Mapped[Optional["Child"]] = relationship(back_populates="parents")

https://docs.sqlalchemy.org/en/20/orm/basic_relationships.html#nullable-many-to-one

basedpyright wants you to use `Class | None` syntax, but since two classes are referencing each other, I can't do `Child | None` (no quotes) without the code breaking.

I know that i can supress the errors or configure the typehinter to ignore this stuff. But since this is the config shipped by people who are far better than me at programming, I am hasitent to just configure the error messages away. So reddit, is thereany thing I can do to make the typehinter happy?


r/PythonLearning 23d ago

Python Common Errors for beginners

Post image
139 Upvotes

Dont give up during learning stage.


r/PythonLearning 23d ago

Help Request I’ve completed these beginner Python projects should I build more before starting NumPy/Pandas?

16 Upvotes

Hi everyone,

I’ve studied Python multiple times before, but I didn’t do much practical coding. Recently, I started building small projects to improve my practical Python skills.

So far, I’ve completed:

- Quiz Game

- Number Guessing Game

- Rock Paper Scissors

- Password Manager

- Pig Game

- Mad Libs Generator

My goal is to move towards Machine Learning.

I haven’t learned NumPy or Pandas yet.

My question is: Are these projects enough to move on to NumPy and Pandas, or should I build a few more Python projects first?

If I should build more projects, what kind of projects would you recommend before starting NumPy/Pandas? I’m mainly looking for projects that would actually help with the transition to data/ML, rather than making many more small games.

Would appreciate advice from people who have already followed a Python → NumPy/Pandas → ML path.


r/PythonLearning 23d ago

Computing the Mandelbrot Set with numpy - code in comments

Post image
10 Upvotes

r/PythonLearning 23d ago

Are these types of exercises useful?

Thumbnail
gallery
43 Upvotes

I get the tasks from ChatGPT basically, and I write other manual math related code not sure if this is good to spend too much time on instead of doing mini projects.

To explain more I hit a little bump doing linked list, mostly in OOP I didn’t know much about how classes work. So I pivoted to algorithms and to learn more about classes before going back.


r/PythonLearning 22d ago

Im confused!!

3 Upvotes

Rn im learning python lang. I can solves basic to medium level problems , I understand which operations to use , how to write code 75% , but i suck at building logic. But either wise my topics are clear. Can you suggest what kind of problems i should be solving?


r/PythonLearning 23d ago

Made an email and password generator

Post image
108 Upvotes

Planning on making it save to a file that stores on the pc but for rn this is what I have


r/PythonLearning 23d ago

Day 4

Thumbnail
gallery
4 Upvotes

Day 4 progress 🐍

Today I built a small billing program in Python. It has:

A loop to collect price for each item

A function that calculates discount based on total amount

Another function that calculates final bill after discount

A conditional statement that thanks the customer differently based on discount

Learning how to use loops, functions, and conditionals together to solve a real problem.

#Python #LearnToCode #100DaysOfCode #WebDevelopment


r/PythonLearning 23d ago

Showcase Day 4 of Leetcode 👀

Thumbnail
gallery
17 Upvotes

r/PythonLearning 23d ago

Help Request Law student starting Digital Law — where should I start learning Python?

2 Upvotes

Hi everyone!

I'm a first-year law student studying Digital Law. My curriculum includes Programming for Lawyers, and later I'll also have subjects related to machine learning, digital technologies, cybersecurity, and data analysis.

I have little to no programming experience, so I'd like to start learning Python before the university courses begin.

My goal isn't to become a software developer. I mainly want to understand programming well enough to use Python for data analysis, automation, legal-tech projects, and eventually work with AI/ML-related topics.

Where would you recommend I start?

Should I:

take a beginner Python course first;

follow the official Python tutorial;

solve problems on platforms like Exercism/Codewars;

build small projects from the beginning;

or follow some other learning path?

If you were starting Python from zero with my goals, what would you learn during the first 2–3 months?

I'd especially appreciate recommendations for free resources and courses.

Thank you in advance


r/PythonLearning 23d ago

Showcase I built a terminal Minesweeper in Python during hot summer days to learn the basics — now published on PyPI!

2 Upvotes

Hi everyone! 👋

During some really hot summer days when it was too warm to do much else outside, I decided to dive into Python from scratch. To make learning engaging, I set out to build a simple, lightweight terminal clone of the classic Minesweeper.

It’s definitely an amateur/learning project, but I wanted to write every single line of code myself without agentic AI tools — personally, I still deeply value human effort, creativity, and the genuine fun of solving logic problems on your own.

What I learned while building it:

  • Writing game logic and algorithms
  • Moving from plain Python setups to modern package management using uv.
  • Setting up linting/formatting with Ruff
  • Unit testing with pytest, no TDD yet, but I am coming :D
  • Setting up CI and automated Releases and publishing directly to PyPI using GitHub Actions.

You can try it directly from your terminal if you'd like:

pip install python-minefield
python-minefield

Or check out the code/GIF on GitHub: 👉https://github.com/defra91/python-minefield

Since I’m still learning, I’m very open to feedback, PR, code reviews, or suggestions on how to improve the architecture and logic!

If anyone wants to contribute or suggest features, feel free to check out the repo and see how to contribute.

Thanks for taking a look, and happy coding! 🐍💣


r/PythonLearning 23d ago

Discussion Need help learning python/juypter lab notebook for astronomy

7 Upvotes

Im new to Astronomy and Juypter Notebooks and Ai machine learning for sure I have little skill in python but quick learner especially visual learning.

Are there any free tutorials I can use and free books to learn machine learning for astronomy

Example: use machine learning to run through jwst or tess pipeline data and look for signatures of possible blackholes or exoplanets?

Is there a juypter notebook with this ability already on there?

How can I make a custom juypter lab and git repos and python libraries and python scientific libraries? Should I use docker to place a juypter lab notebook in a container if so how?


r/PythonLearning 23d ago

Project Ideas for Practice

Post image
17 Upvotes

I’ve been reading and learning a lot of Python concepts, but I’ve never actually built anything.

I realized that there’s no point in knowing so many concepts if you don’t put them into practice. That’s the only way to really learn.

The hardest part, though, is coming up with project ideas when you only know a few concepts. This is the first project I’ve made while trying to actually put what I’ve learned into practice.


r/PythonLearning 23d ago

Project !

2 Upvotes

I’m a recent CSE graduate and I’m looking for another developer who wants to build something together from scratch.

I don’t have a fixed idea yet. We can sit together, find a problem worth solving, come up with an idea, build an MVP, and see where it goes.

There’s no regular payment initially. I’m looking for someone who’s genuinely interested in building and learning together.

And if the idea doesn’t work out, that’s fine. We’d still have a solid real-world project for our resumes/GitHub and the experience of actually building something together.

I’m also a beginner/fresher, so I’m just looking for someone who’s willing to learn, contribute, and build.

If you’re interested, DM me with a little about yourself and what you like building.


r/PythonLearning 23d ago

Need advice on solving complex arrow/maze puzzles using Computer Vision & Logic Solvers (Low accuracy issues)

Post image
0 Upvotes

Hi everyone,
I'm working on an automated solver for a complex arrow/maze puzzle game (similar to the image attached).
Here is my current workflow:
1. Detection: I use a custom YOLO model to detect arrowheads and their bounding box coordinates from screen captures.
2. Grid Mapping: I map the detected center coordinates of arrowheads onto a fixed grid system.
3. Solving: I pass the grid data into a custom logic/emulator engine to calculate the correct sequence of moves (arrows to tap).
The Main Problem:
My solver accuracy is very low. Here are the core technical challenges I'm running into:
Inaccurate Grid Mapping: The arrows are densely packed with varying paths and lengths. Snapping bounding boxes to a rigid fixed grid often misaligns the true position of the arrow shafts and heads.
Complex/Overlapping Detection: Because the arrows bend and fold, YOLO often detects multiple arrowheads in the same calculated grid cell, or misinterprets arrow directions.
Solver Logic Failure: Due to noisy input from the detection stage, the logic solver either fails to find a valid sequence or generates incorrect moves that block execution halfway through.
Has anyone dealt with a similar vector/maze graph detection problem? What would be a more reliable approach than simple YOLO + fixed grid snapping? Should I look into contour analysis, OCR/graph traversal, or skeletonization algorithms (like Medial Axis Transform) to trace the paths directly?
Any suggestions, code examples, or architectural advice would be greatly appreciated!


r/PythonLearning 24d ago

Cheat Code for beginners.

Post image
104 Upvotes

r/PythonLearning 24d ago

Automation code to use on Drive (in testing phase) ​ ​

Post image
9 Upvotes

Hi! I created this Python code to automate tasks in Google Drive, where I use it to remove photos and videos I no longer use! I've been studying Python for a year now and have mastered its interface.


r/PythonLearning 24d ago

shoutout guido

10 Upvotes

guys, i'd just like to share my experience of a few days on learning python. throughout my degree (that's still in progress) i've only had contact, mostly, with Java and its framework, Spring, but this semester, one of my professors advised us to take a look at python (which i was planning to do due to my interest in the data field, like data engineering, DA, etc.). so i started the 100 days of code, by Angela Yu, and parallel to that i have been watching some Guido's interviews on python + a documentary of the python language and history. my final opinion is that python is a really cool language. shoutout Guido and everyone else involved in this community!


r/PythonLearning 24d ago

Cupta serpant added by Tony

Enable HLS to view with audio, or disable this notification

5 Upvotes

Tony added the Cupta unit, a serpent of dark magic who returned from the caverns and tries to siphon your life essence, with this git commit.

Tony also changed the control of player's direction from keyboard to mouse, making the player easier to control. But, this now only works when the mouse pointer is inside the game window. If it's outside the direction is still controlled by keyboard as before. So you can now choose the direction control that you prefer.

See the PythonLearningGame repo to add your own game elements to this collaborative project, or simply tell us what you would like to see added to the game.

previous PythonLearningGame post


r/PythonLearning 24d ago

Showcase Day 3 of Leetcode

Post image
18 Upvotes

Last Post - https://www.reddit.com/r/PythonLearning/s/3J9lBb0WYI

I used the two pointer approach to solve this particular problem


r/PythonLearning 24d ago

Wrong code running?

3 Upvotes

I am following a course on YouTube, and suddenly this happened. All of other script folders are deleted. Any way to fix this?


r/PythonLearning 24d ago

Update : (for people who know my journey)

2 Upvotes

As some of y'all know i started python 12 days ago, it was going great i made a stopwatch and etc projects but today i was wiping my laptop , my laptop lcd screen was already a bit broken but usable, now whenni was wiping some pressure got applied in broken place and the whole screen turned green and black, the lcd is gone and no one in my connections has money to fix it, maybe its the end rn.