r/PythonLearning 5d ago

Help Request what do you think ?

Thumbnail
gallery
42 Upvotes

i'm learning python for infraestructure this a proyect of a false resgistry of server xd


r/PythonLearning 6d ago

I build this after learning OOP

Post image
361 Upvotes

r/PythonLearning 5d ago

Help Request I'm trying to build a budgeting app.

2 Upvotes

I need to create a chart that looks like this:

100|          
 90|          
 80|          
 70|          
 60| o        
 50| o        
 40| o        
 30| o        
 20| o  o     
 10| o  o  o  
  0| o  o  o  
    ----------
     F  C  A  
     o  l  u  
     o  o  t  
     d  t  o  
        h     
        i     
        n     
        g     

i need to calculate the percetages spent in each category and represent them in the chart.

so far, through SO much struggling ive gotten it to return only the first category and i got it to put all the categories in a dictionary correctly.

(c_w dictionary)

I seriously don't know where to get the answer, I've done a bunch of searching and asked on other forums for help and i jsut cant get it

im fed up.

import math
class Category:
    def __init__(self, name):
        self.name = name
        self.ledger = []


    def deposit(self, amount, description=""):
        self.ledger.append({"amount": amount, "description": description})


    def withdraw(self, amount, description=""):
        if self.check_funds(amount):
            self.ledger.append({"amount": -amount, "description": description})
            return True
        else:
            return False


    def get_balance(self):
        balance = 0
        for transaction in self.ledger:
            balance += transaction['amount']    
        return balance


    def check_funds(self, amount):
        return amount <= self.get_balance()


    def transfer(self, amount, destination_category):
        if self.check_funds(amount):
            self.withdraw(amount, f"Transfer to {destination_category.name}")
            destination_category.deposit(amount, f"Transfer from {self.name}")
            return True
        else:
            return False
    def __str__(self):
        method = '\n'.join(f"{transaction['description']:23.23}{transaction['amount']:>7.2f}" for transaction in self.ledger )
        return f"{self.name.center(30,'*')}\n{method}\nTotal: {self.get_balance()}"
    def __iter__(self):
        for item in self.ledger:
            return item
def create_spend_chart(categories):
    #create the header text
    header = 'Percentage spent by category'
    #create the percentages down the left side
    
    #a 
    total_withdraw = 0 
    #create a list for the category withdraws
    c_w = {} 
    amounts = [transaction['amount'] for category in categories for transaction in category.ledger]
    for amount in amounts:
        if amount < 0:
            total_withdraw += -amount
    # Calculate withdrawals for each category
    for category in categories:
        withdrawal = 0
        for transaction in category.ledger:
            amount = transaction['amount']
            if amount < 0:
                withdrawal += -amount  # Add the amount spent (negative for withdrawals)
        c_w[category.name] = withdrawal
        method = math.floor(( c_w[category.name]/total_withdraw)*100)
    
    return f'{header}\n{name}: {method}' for i in c_w
food = Category('Food')
auto = Category('Auto')
food.deposit(1000, 'initial deposit')
auto.deposit(1000, 'initial deposit')
food.withdraw(10.15, 'groceries')
food.withdraw(15.89, 'restaurant and more food for dessert')
clothing = Category('Clothing')
food.transfer(50, clothing)
food.withdraw(100.99)
clothing.withdraw(21.17)
auto.withdraw(200)




print(create_spend_chart([food, clothing, auto]))

r/PythonLearning 5d ago

How would I optimize this?

Thumbnail
gallery
8 Upvotes

I'm currently learning python with the 30 days of python GitHub repo and, on day 3 of the challenge, it asks to create this table and this is what I came up with however I feel like there was a more efficient method to create it or is it something that I haven't learned yet at my level.


r/PythonLearning 5d ago

A zero-dependency physics engine with natural language parsing and dimensional analysis

2 Upvotes

I am pleased to share a project I have been developing: the Extensible Physics Simulator Engine. This is a domain-agnostic engine written in pure Python designed to parse natural-language physics queries, perform strict dimensional analysis, and manage multi-tier unit conversions.

Motivation

Most existing libraries require highly structured input data. My objective was to construct a robust text-parsing layer capable of mapping plain-English queries directly to physical formulas without relying on extensive external dependencies.

Technical Highlights

  • Self-Registering Plugins: Physics domains, such as free fall, projectile motion, and circular motion, register themselves via explicit SlotSpec and TargetSpec definitions. Consequently, the core parser does not require modification to accommodate new domains.
  • Tiered Fallback Policy: The unit engine resolves equations across multi-tier conditions based on explicit unit data (ranging from Fully-Explicit and SI-Fallback to Pure Magnitude).
  • Zero Dependencies: The parsing engine and formula-derivation layer utilize only the standard library (the optional terminal TUI utilizes Textual).

The repository includes a comprehensive unit test suite and documentation detailing how to extend the architecture for additional domains, such as thermodynamics or orbital mechanics.

I would greatly appreciate any feedback regarding the symbolic equation-derivation layer or the overall architectural design.

Repository: https://github.com/Nomaan2010/Extensible-Physics-Simulator-Engine


r/PythonLearning 5d ago

Ability selector v0.1

1 Upvotes

Hey guys! I made an update in my code!


r/PythonLearning 5d ago

Some projects to make in Python?

6 Upvotes

I wanna create more projects in Python. What’s a good place to search, or a place that guides you?


r/PythonLearning 5d ago

Help Request I am trying to download python manager on a pretty old computer

Post image
4 Upvotes

I am very new to python and computers in most cases and I am following a guide but I got to this point and it is giving me this message. I am using a windows 10 education and it is a few years old I am wondering will I be able to download python or do I need a new computer?


r/PythonLearning 5d ago

Help Request How do I draw an empty list in a frame diagram ?

Post image
6 Upvotes

r/PythonLearning 5d ago

What is API?

31 Upvotes

I'm new to coding and programming languages and i frequently come across the word API. Can anyone help me understand what that is?


r/PythonLearning 5d ago

Help Request Help me pick between two Python resources

6 Upvotes

Hey! So I found two different ways to learn Python and I honestly can't decide which one to go with. Don't wanna waste time on something that sucks, so figured I'd ask you all.

1) https://www.learnpython.org/

2) https://www.edx.org/learn/python/harvard-university-cs50-s-introduction-to-programming-with-python

Basically I'm trying to figure out:

  • Which one actually explains stuff in a way that makes sense?
  • Are they actually engaging or boring af?
  • Do you actually get to code or is it just videos?
  • Does it feel like they're rushing you or going too slow?
  • Any major downsides I should know about?
  • Will it actually help me build stuff or is it just theory?

I'm still kinda new to all this so I'm just looking to get the basics down. Would love to hear what people think, especially if you've tried either of these!

Thanks in advance :)


r/PythonLearning 5d ago

How long will it take me to learn Pandas library?

7 Upvotes

r/PythonLearning 5d ago

Creating our own game with the PythonLearning community

15 Upvotes

I thought it might be fun to build our own Python game together as members of the PythonLearning community. What else were you planning to do this summer anyway? We can use this simple game in this git repo as starting point:

PythonLearningGame

It's purely educational, a great opportunity to learn about: - Python - PyGame - (quick and dirty) Object Oriented Programming - Teamwork using GIT

This should be accessible for Python students who are comfortable with loops, functions, and classes.

Get creative and make your contribution to this game, maybe: - change behavior - add a new unit type - add special effects - add new game dynamics - add better graphics - ... (what ever you like, but keep it civilized)

Drop a comment if you feel this might be good educational fun and you might want to contribute.

See the PythonLearningGame repo for instructions. If things are not clear or you get stuck, ask AI or ask questions in the comments.

previous PythonLearningGame post


r/PythonLearning 5d ago

What was the first Python project that made everything finally "click" for you?

16 Upvotes

I've learned the basics like variables, loops, functions, lists, dictionaries, and now I'm starting small projects. I'm curious—what was the first project that really helped you understand how everything fits together? I'd love to hear your experiences.


r/PythonLearning 5d ago

Help Request How to reset progress in 100 Days of Code?

4 Upvotes

I'd like to start over; is there a way to remove any progress I've made?

I don't want to see any code from my previous exercises.


r/PythonLearning 5d ago

Why nobody uses the IDLE Shell?

4 Upvotes

I was just wondering why nobody uses the pre-installed IDLE Shell from Python? I am a beginner, I use my 16 years old laptop and it gets the job perfectly done, at least for me. Anyone with different opinion?


r/PythonLearning 6d ago

my first python

Post image
25 Upvotes

kindly give ratings and tips to improve


r/PythonLearning 5d ago

What's a Python habit you wish you had started much earlier?

4 Upvotes

Looking back, what's one habit that made your code noticeably better?

Could be anything like:

  • Writing tests
  • Using virtual environments
  • Type hints
  • Logging
  • Reading the docs first
  • Black or Ruff
  • Git commits
  • Better project structure

I'm curious what habit had the biggest long-term payoff for you.


r/PythonLearning 5d ago

Ability selector

3 Upvotes

"Hey everyone! I'm learning Python and just made this text-based ability selector. I uploaded it to GitHub here: https://github.com/ibtsch2012-art/abilityselector. I'm looking for feedback on how to clean up my code or what cool features I should add next!


r/PythonLearning 6d ago

Help Request Good Textbooks on Amazon? Looking for the best Python textbooks to rebuild fundamentals and deepen understanding.

5 Upvotes

I’ve learned Python before and recently completed a refresher certificate, but I still find myself forgetting certain concepts. I want to strengthen my foundation without relying on AI tools like ChatGPT or Claude.

For those of you who’ve learned Python through books, which textbooks helped you the most? I’m especially interested in recommendations that:

• rebuild core fundamentals
• offer structured practice or projects
• help transition from beginner to intermediate/advanced
• stay relevant for modern Python (3.10+)

I’d really appreciate hearing what worked for you and why.

Thanks in advance.


r/PythonLearning 6d ago

Indentation error 😭(help)

Thumbnail
gallery
3 Upvotes

I cant seem to find whats wrong , maybe the issue is with the Template or wrong expectations?

class UserMainCode(object):

@classmethod
def sumOfNonPrimeIndexValues(cls, input1, input2):
    '''
    input1 : int[]
    input2 : int

    Expected return type : int
    '''

    # Read only region end

    total = 0

    for i in range(input2):
        if i < 2:
            total += input1[i]
        else:
            prime = True
            for j in range(2, int(i**0.5) + 1):
                if i % j == 0:
                    prime = False
                    break

            if not prime:
                total += input1[i]

    return total

Also they expect return type is int[] but we got sum?? Idk I couldn't take screenshot coz its a daily assessment platform


r/PythonLearning 5d ago

Best free AI in Python

0 Upvotes

Many of us will agree that in Python, and in coding, Claude is the best. But what about free models, like deepseek, nemotron, hy3, Mimi 2.5 and etc.

For me it’s Deepseek and Hy3 In high thinking. What do you think?


r/PythonLearning 5d ago

Agent Pal – An interactive desktop companion for AI coding agents (Claude Code, Codex, Antigravity, and more)

Post image
1 Upvotes

Hey r/PythonLearning,

I've been working on a fun open-source project called Agent Pal that brings AI coding agents to life on your desktop.

It's a Python application built with PyQt that automatically detects terminal-based AI agents like Claude Code, Codex CLI, Antigravity, and others. Whenever an agent starts running, Agent Pal spawns a unique animated companion on your desktop or taskbar. When the agent exits, the companion disappears automatically.

Features

  • 🤖 Agent-specific mascots Each supported AI agent has its own unique character. For example:
    • Antigravity appears as a floating blue astronaut.
    • Claude Code appears as a coral-colored terminal with blinking green CLI eyes.
  • 🎬 Live activity animations The mascots react to what the AI is doing:
    • Typing on a tiny keyboard while generating code.
    • Inspecting with a magnifying glass while researching or analyzing.
    • Idle animations when they're waiting.
  • 🔔 Attention notifications If an AI agent is waiting for your input and you've switched to another window, the mascot displays a red ! speech bubble so you don't miss it.
  • 🖱️ Double-click to return Double-click a mascot to instantly focus its associated terminal window (including Windows Terminal tabs).
  • 🐞 A fun mini-game Right-click anywhere to spawn a crawling "code bug." Your AI companions will chase it, jump on it, squash it, and celebrate when they succeed.

Tech Stack

  • Python
  • PyQt
  • Runs locally on Windows
  • Fully open source

GitHub: https://github.com/tahirrbagwann/agent-pal

I'd love to hear your thoughts! Feature requests, mascot ideas, bug reports, and contributions are all welcome.


r/PythonLearning 6d ago

Convert PDf to PDF/A for free without internet

1 Upvotes

Hi

For a project i have to convert PDF file to PDF/A format.

For now i'm using a local StirlingPDF Docker, and send my file with a KSH script to convert then to PDF/A

But i'm wondering if there is a free python module allowing that, that don't require an internet connection.

I found some paid module, and some paid module also require internet connection :/


r/PythonLearning 6d ago

Best Resources for Free Python Learning?

7 Upvotes

Broke newbie here. I've tried learning to code a few times but it's never stuck. I want to give it another go but properly this time as I have a good laptop and a few free hours during my day.

What are the best ways to learn python for free? I already picked up Automate the boring stuff with Python and wanted to find perhaps some free courses or in depth youtube guides that maybe have "homework" of sorts? A lot of what I did in the past was following along with tutorials which obviously didn't teach me much of anything.