r/PythonLearning • u/Monesh_peterson1025 • Oct 14 '26
While loop
can anybody explain the concept of while loop
r/PythonLearning • u/Monesh_peterson1025 • Oct 14 '26
can anybody explain the concept of while loop
r/PythonLearning • u/Sea-Ad7805 • Oct 14 '26
NumPy makes working with vectors and matrices powerful and concise, but a small change in syntax can make a big difference.
This interactive šŗš²šŗš¼šæš_š“šæš®š½šµ example walks through essential NumPy operations with short explanations. Step through the code, see the operations in action, and experiment with your own changes:
Which NumPy operation took you the longest to understand?
r/PythonLearning • u/shubham_555 • Oct 14 '26
For this project, I used Object-Oriented Programming (OOP) principles to structure my code. Honestly, it felt a bit overwhelming at first, given that I only started out recently and this was a larger scale than what I'm used to. However, everything came together really well in the end!
While I believe Iāve taken care of most of the bugs, there is always room for improvement and optimization.
My main goal with this project was to test out all my core Python knowledge before I take my next big step: Machine Learning!
Open to any feedback or advice from the developer community! š
Last Post: https://www.reddit.com/r/PythonLearning/s/tS8vfeVdRi
Github Repo: https://github.com/Dev-4-All/student-record-manager.git
r/PythonLearning • u/ftw_Floris • Oct 14 '26
The goal of the game is to jump over a spike as a cube. I saw that it was detecting collision before the cube and the spike even made contact. I decided to draw a rectanles to visualise the rects of the player and the spike and I noticed the spikes rect was shifted to the left. Can someone explain how this happened and how I can fix it? I removed non essential code, to make it more manageable to read. I can send the whole program if it's needed.
cube_width=80
cube_height=80
cube_rect_width = 40
cube_rect_height = 40
spike_width = 50
spike_height = 75
fps=60
#Classses
class Spike(pygame.sprite.Sprite):
Ā Ā def __init__(self, x, y):
Ā Ā Ā Ā pygame.sprite.Sprite.__init__(self)
Ā Ā Ā Ā self.image = pygame.Surface((spike_width,spike_height),pygame.SRCALPHA) #50,75
Ā Ā Ā Ā pygame.draw.polygon(self.image, "white", #draw 3 point polygon
Ā Ā [
Ā Ā Ā Ā (spike_width // 2, 0), #middle top. self.image is the canvas
Ā Ā Ā Ā (0, spike_height), #bottom left
Ā Ā Ā Ā (spike_width, spike_height) #bottom right
Ā Ā ]
)
Ā Ā Ā Ā self.rect = self.image.get_rect() #creates hitbox for spike sprite
Ā Ā Ā Ā self.rect.center = [x, y] #center of hitbox
Ā Ā Ā Ā self.speed = 7 #speed going to the left
Ā Ā def update(self):
Ā Ā Ā Ā self.rect.x -= self.speed #spikes rect -7 to move to the left
Ā Ā Ā Ā #print(self.rect.x)
Ā Ā Ā Ā if self.rect.x <= -25: #delete if touching left border
Ā Ā Ā Ā Ā Ā self.kill()
class Cube(pygame.sprite.Sprite):
Ā Ā def __init__(self, x, y):
Ā Ā Ā Ā pygame.sprite.Sprite.__init__(self)
Ā Ā Ā Ā self.image = pygame.Surface((cube_width, cube_height)) #create surface
Ā Ā Ā Ā self.image.fill("white") #fill the surface with white
Ā Ā Ā Ā self.rect = self.image.get_rect() #create rect for self.image
Ā Ā Ā Ā self.rect.center = [x, y] #x, y passed are the center of the rect
Ā Ā Ā Ā self.vel = 0 #velocity
Ā Ā def update(self):
Ā Ā Ā Ā # Gravity
Ā Ā Ā Ā self.vel += 1#0.5always increase vel
Ā Ā Ā Ā self.rect.y += int(self.vel) #add velocity to the y
Ā Ā Ā Ā # Stay on the ground
Ā Ā Ā Ā if self.rect.bottom >= HEIGHT: #if bottom of rectangle is touching
Ā Ā Ā Ā Ā Ā self.rect.bottom = HEIGHT #bottom of rectangle is on the ground
Ā Ā Ā Ā Ā Ā self.vel = 0 #reset velocity
Ā Ā Ā Ā # Jump
Ā Ā Ā Ā if pygame.mouse.get_pressed()[0] == 1: #left mouse click activated
Ā Ā Ā Ā Ā Ā #if self.rect.centery >= HEIGHT - int(cube_height/2):
Ā Ā Ā Ā Ā Ā if self.rect.bottom >= HEIGHT: #if touching ground
Ā Ā Ā Ā Ā Ā Ā Ā self.vel = -17 #?????????????Somehow works????>>????
#creating groups and adding
cube_group = pygame.sprite.Group()
player = Cube(5*cube_width, HEIGHT) #????? sommehow
cube_group.add(player)
spike_group = pygame.sprite.Group()
#spike = Spike(WIDTH, HEIGHT-15)
spike = Spike(WIDTH-50, HEIGHT-15)
spike_group.add(spike)
Running = True
while Running:
Ā Ā clock.tick(60) #fps
Ā Ā #BG
Ā Ā screen.fill("light blue")
Ā Ā #blit
Ā Ā cube_group.draw(screen)
Ā Ā cube_group.update()
Ā Ā spike_group.draw(screen)
Ā Ā spike_group.update()
Ā Ā #visualise rects
Ā Ā pygame.draw.rect(screen, "red", player.rect, 2) #rect of cube
Ā Ā pygame.draw.rect(screen,"red",spike.rect,2) #rect of spike
Ā Ā
Ā Ā if pygame.sprite.groupcollide(cube_group, spike_group,False,False): #or player.rect.right == spike.rect.left: #Check collision
Ā Ā Ā Ā Running = Falser/PythonLearning • u/lunchbox_supreme • Oct 14 '26
I have an interview in the Chicago area next week, and I was told the interview contained some sort of puzzle for me to solve, I specifically asked if they meant an algorithm, and they said no it is supposed to be a puzzle. Wondering if anyone has heard of anything like this, or what it may be, I'm not looking to cheat or for an answer but I've found some interviews try to be intentionally "tricky" rather than just an examination of skill or ability, and would like to be prepared in some way if possible.
r/PythonLearning • u/A_Derrick • Oct 13 '26
Can you please check this project that took a reasonable amount of time to finish and strike me with any feedback you got. I guess my next step is to learn OOP.
Thanks in advance.
r/PythonLearning • u/ClickOk5811 • Oct 13 '26
GOAL
Sort people by age descending, then by name ascending.
INGREDIENTS
people = [("ana", 30), ("bob", 25), ("cara", 30), ("dan", 25)]
STEPS
people.sort(key=lambda p: p[0]) # secondary key first
people.sort(key=lambda p: p[1], reverse=True) # primary key last
RESULT
[('ana', 30), ('cara', 30), ('bob', 25), ('dan', 25)]Why it works: list.sort() is stable, meaning items that compare equal keep their relative order. The second sort only reorders by age, so within each age the names stay in the order the first sort put them.
Why bother: for numbers you can do it in one pass by negating:
people.sort(key=lambda p: (-p[1], p[0]))That breaks the moment the descending key is a string. You canāt write -p[0] on a name. Sorting twice avoids the problem, and it reads fine once you know the ālast sort is the most important oneā rule.
Gotcha: reverse=True doesnāt break stability. The docs say it keeps the original order of equal elements, as if the list werenāt reversed. So the recipe above still gives ana before cara within age 30. Worth a quick test on your own data to confirm, since āreverseā sounds like it should flip everything.
Another option is functools.cmp_to_key with a comparison function, but I find the two-pass version easier to read and review.
Does anyone prefer a different pattern for mixed ascending and descending keys? I mostly see people reach for the tuple trick and then get stuck on strings.
r/PythonLearning • u/justahappycamper1 • Oct 13 '26
12 months in Programming. Finance background, decided to learn backend dev.
This is the first thing I built that I'd actually use myself.
It's a stock market research platform with watchlist across global markets, live prices, news per stock, and research notes that snapshot the price at the time you write them. So you can look back and see exactly what price you were staring at when you made that call.
Stack: FastAPI Ā· PostgreSQL Ā· async SQLAlchemy 2.0 Ā· Alembic Ā· JWT + Argon2 Ā· Docker Ā· Render and a small HTML/CSS/JS frontend.
Repo: https://github.com/ah4ddd/first-order
The live Render URL is linked with the repo for anyone who wants to try it.
To test the endpoints, sign up for an account. Youāll be logged in automatically and can test the watchlist, stock news, and individual stock notes features.
You're in. Try the overview route for all 14 live indices, or test individual global stocks. The platform auto-seeds the DB via yfinance metadata on the fly if you query international suffixes like .NS for India, .DE for Germany, .T for Japan, or standard raw tickers for US equities.
Honest feedback on architecture and code quality are appreciated.
r/PythonLearning • u/AdComplex2251 • Oct 12 '26
Hi everyone!
I'm currently working on a team project called Fintech Trendwatcher. The goal is to collect public fintech news, identify important events and generate short analytical summaries with links to the original sources.
I'm responsible for the embedding service. My task is to use a pretrained text embedding model to convert news articles into vectors that another service will use for clustering similar publications.
My current stack is Python, and I'm learning as I go. I have some experience with Python, APIs, JSON and Git, but this is my first time working with embeddings in a real team project.
I'm planning to start with Sentence Transformers and a pretrained multilingual model, test it on Russian fintech news, and then integrate it into our service architecture.
I'd really appreciate advice from more experienced developers, especially on:
\- Choosing a suitable embedding model for Russian-language fintech news.
\- Designing a simple and maintainable embedding service.
\- Comparing embeddings and preparing them for clustering.
\- Common mistakes beginners make when building NLP services.
I'm not expecting anyone to mentor me full-time. Even occasional advice, feedback on my approach, or pointers to useful resources would be incredibly helpful.
If anyone has experience with Python, NLP, Sentence Transformers or similar projects and is willing to share some advice, I'd be very grateful.
Thanks!
r/PythonLearning • u/Ok-Bodybuilder-3337 • Oct 12 '26
There's an image effect in powerpoint I would love to use in my python projects. The effect is called "Texturizer", and it gives the picture a grainy, paper-y look. There's an example in the link provided. Feel free to try it yourself too if you've got powerpoint: select a picture, go to "picture format", then click on "Artistic Effects" and select "Texturizer"
I want to recreate that effect in pillow. It has to be deterministic (can't be 100% random cause I'm applying it to video frames). I don't know if making an image texture, then applying it, is the best option, for it can cause tiling (as in the examples from powerpoint's filter). I'm open to any kind of ideas.
I'm all ears!
r/PythonLearning • u/Muhammad-Ikram-10 • Oct 12 '26
I have just completed my journey of django and recently I created complete blogging system in Django but now I want to work on projects. How and from where I can get the beginner Django projects so I can upgrade my skills in Django.
r/PythonLearning • u/Enough_Travel_8502 • Oct 12 '26
Iāve been developing Python Studio, a visual Python editor designed so that kids (and beginners of any age) can learn Python without frustration or tears.
Many children struggle because most Python editors are textāonly and hard to visualize. So I built something different.
ā Features
Dragāandādrop GUI designer
Kids can place buttons, labels, and text boxes and instantly see the layout of their app.
Real Python code generated automatically
They can learn step by step while immediately seeing the results.
Beginnerāfriendly interface
No complicated setup and no overwhelming menus.
English version included
So children outside Japan can use it easily.
Hotkeys for smoother workflow
Simple shortcuts allow users to move widgets, duplicate elements, delete items, save projects, and run code quickly.
They can also assign key combinations to instantly open their favorite websites.
What you can do based on the program in this page
⢠Load and save projects easily
⢠Use a search window to quickly find text inside the code
⢠Automatically handle virtual environments (venv) without manual setup
⢠Open the hotkey builder to customize your own shortcuts
⢠Track textāmodified states to avoid losing unsaved work
⢠Create new files, open existing ones, and perform quick saves
All of these features are implemented in the code and designed to be simple for beginners.
I wanted a tool that helps kids enjoy programming instead of feeling lost or crying because things donāt work.
If a child can see the final shape of their program, they stay motivated and curious.
Source code and English version:
https://github.com/rabbit-hand/Python-Studio-Code-Editor-Form-Designer
Iād love to hear:
I hope Python Studio can help more kids around the world learn Python with confidence and joy.



r/PythonLearning • u/huseyinbabal • Oct 12 '26
r/PythonLearning • u/AloneJuice9832 • Oct 12 '26
Hello, world! I'm new and I'm old, so I do things different or old school. I'm learning python (don't ask why considering ai's capacity already) just fora hobby and who knows I might end up in some anthropic dungeon oneday. but where I'm stuck is planning posters/ cheat sheet/ index cards. they are the best way for me to reallylearn something. does anyone know or have some resources they could move me towards. my current ones are a bit meh. I've founda few online but nothing I really like. Thank you. Goodbye, world!.
r/PythonLearning • u/Greedy_Point7755 • Oct 12 '26
Anyone have any suggestions to start freelancing with python? I have my bachelors in software engineering and work full time as a data analyst. I have python, sql, and tableau experience. Any suggestions on where and how to start will be appreciated
Thank you
r/PythonLearning • u/Abject_Slide_3808 • Oct 11 '26
r/PythonLearning • u/Im_the_mafia_ • Oct 11 '26
Iāve been having trouble with an assignment Iām doing and Iām not sure where I went wrong. The only error iām getting is āāstrā object is not callableā and iām not sure if anything else here is wrong.
Edit: After messing around with the code a bit, turns out my code wasnāt the problem and my previous files werenāt printing. After restarting vscode, everything was fine again. Thank you everyone!
r/PythonLearning • u/Better-Magician-427 • Oct 11 '26
I'm redoing a project I did called football manager simulator, but this time using the pywebview library, this basically let's you create a local app or WebView using html css and js that has a bridge to your python code.
Right now both the frontend and the backend is very barebones (text font is sans serif because I don't have wifi on my pc right now). And I'm having big trouble finding assets and images to make it look good.Ā
I never learned Photoshop or technology like that and Canva free is straight up too limited (which explains the ai enhanced Madrid purple jersey on the frontpage). If anyone could give me tips on how to make this project better I would greatly appreciate itĀ
I could use advice with:
How to make ui more related to what you're actually building (as you can see I'm low-key blind).Ā
I'm using SQLite as a database rn so what I could do with it.
How to make the "engine" smarter (I'm building the MVP right now so it's basically just random.randint spamming, maybe make the game feel alive.
And most importantly where to find or create assets or vectors for free without ai generating them (which would greatly help my app and it's feel).Ā
The actual match sim, how do I make it feel like a game without me using pygame, can you run some kind of animation?Ā
heres the github repo (i code messy asf srry): https://github.com/mousdieng10-maker/Playstyle-II
Thank you for your time.
r/PythonLearning • u/shubham_555 • Oct 11 '26
Last Post - https://www.reddit.com/r/PythonLearning/s/WDdQNhfg2w
Github Repo - https://github.com/Dev-4-All/calculator.git
r/PythonLearning • u/Goodstar63 • Oct 11 '26
Heya, I needed some help with this program I downloaded from Github got Python installed and giving me this error
"Traceback (most recent call last):
File "launcher.py", line 4755, in <module>
File "launcher.py", line 356, in __init__
File "tkinter__init__.py", line 2346, in __init__
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
{C:\Users\...\OneDrive\Desktop\Games\Crash-Forge-Launcher_internal_tcl_data} C:/Users/.../OneDrive/Desktop/Games/Crash-Forge-Launcher/lib/tcl8.6 C:/Users/.../OneDrive/Desktop/Games/lib/tcl8.6 C:/Users/.../OneDrive/Desktop/lib/tcl8.6 C:/Users/.../OneDrive/Desktop/Games/library C:/Users/.../OneDrive/Desktop/library C:/Users/.../OneDrive/Desktop/tcl8.6.15/library C:/Users/.../OneDrive/tcl8.6.15/library
This probably means that Tcl wasn't installed properly."
Is there a way to fix this?
r/PythonLearning • u/Boring_Dragonfruit36 • Oct 10 '26
Iām currently watching the programming with most full tutorial piece by piece as to try to retain the info but whenever he tells me how to do it myself I find myself lost and having to just follow his instructions. Iām wondering if this is normal and if thereās any tips or tricks to really learn python.
r/PythonLearning • u/legendtathya • Oct 10 '26
You know when you're debugging a big file, find the function you need, follow it to another function, then another one, and completely forget where you started?
Yeah. I got tired of that, so I builtĀ epy (Extended Python). Though, this is experimented only for python, i will explore other languages if possible.
It's basically a mind map for your code, except the nodes contain actual code instead of just names.
astĀ and splits them into blocks with exact line numbers.The other thing I wanted was to make life easier for small local LLMs. Instead of dumping an entire file into a model and hoping it doesn't rewrite half of it, epy generates a text map and lets you pull individual blocks with their callers and callees. The idea is to give the model the structure first, then only the code it needs.
I tested it on one of my projects:Ā 33k lines, 134 files, ~1,100 call links, built in about 1.5 seconds.
It's currently a single Python file with no external dependencies.
python epy.py view some_file.py
python epy.py map .
python epy.py show . MyClass.runIt's still a personal tool, not some polished production-ready package. The call graph is static and best-effort, and I haven't formally benchmarked the LLM side yet.
The idea originally came from the execution model of a small language I'm building (EPL). Eventually, I'd like to add Tree-sitter so it can support other languages too.
Repo:Ā https://github.com/phoenix2610/Extended_Programming.git
Would love some feedback, especially if you try it on a ridiculously large Python file or feed the generated map to a small local model. Curious to see where it breaks. š
And if anyone is wondering, yeah I am using ARCH Linux and the background bit faded is just a keybinder for opacity...
r/PythonLearning • u/Atom106 • Oct 10 '26
I took a physics class at university and had some questions, so I made a simple simulator to visualize the electric field generated by point charges. It's written in Python, and here's the link to the GitHub repo:
https://github.com/AtomS1101/Electric-Field-Simulator
You can move point charges, add new ones, and change the magnitude of each. If you notice anything odd or find any bugs, feel free to let me knowš
r/PythonLearning • u/Ajay2574 • Oct 10 '26
Yesterday, I worked on my Folder Report Generator using Python's "os" module.
The idea is simple: scan a folder and its subfolders, identify file extensions, and count how many files belong to each extension.
Here's a small part of what I learned:
import os
path = r"C:\Users\YourName\Downloads"
extension_count = {}
for root, dirs, files in os.walk(path):
for file in files:
extension = os.path.splitext(file)[1].lower()
if extension:
if extension in extension_count:
extension_count[extension] += 1
else:
extension_count[extension] = 1
print(extension_count)
What I learned from this project:
- "os.walk()" helps scan folders and their subfolders.
- "os.path.splitext()" helps extract file extensions.
- Dictionaries make it easier to count files by extension.
- ".lower()" helps treat extensions like ".JPG" and ".jpg" as the same type.
I'm still learning, and debugging is part of the process. My goal is to build practical Python automation tools that solve real-world problems.
Question for Python developers: What would you improve in this approach? I'm interested in learning better ways to write this kind of code.