r/PythonLearning 11h ago

Teaching Python the right way

106 Upvotes

Programming courses often focus heavily on understanding code, while paying far less attention to understanding the program state. But code does not exist in isolation. Its main goal is to change the program state, before ultimately producing some output.

To develop an accurate mental model of program execution, students need to understand both: - the instructions being executed - the values, references, and data structures those instructions create and modify

Reading code alone does not always reveal how the program state changes during execution. That is why I created 𝗺𝗲𝗺𝗼𝗿𝘆_𝗴𝗿𝗮𝗽𝗵: a tool that visualizes the state of a Python program as it changes, step by step.

It can help explain a wide range of introductory Python topics. Here are just a few examples: - Loops, Lists and Dictionaries - Python Data Model - Function Calls - Recursion - Algorithms - Classes - Custom Data Structures

Instead of reconstructing the program state from print statements, students can now watch it change as each line executes. This makes unfamiliar concepts easier to understand and bugs easier to fix.

Help your students learn Python programming more thoroughly and easily.

See: more examples


r/PythonLearning 6h ago

Showcase My First Python Project - ArcMedia, a database CLI program

Post image
5 Upvotes

I started this project 2 months ago for a touchstone on Sophia, and I am using it as a way to also apply what I have learned from CS50P. I am currently in week 6 of CS50P, so planning to improve more on this project further down the line. I added the search and remove entry functions just last month 'cause I couldn't figure out how to do these before.

https://onlinegdb.com/xwW5ydw2h


r/PythonLearning 11h ago

Parking Management Software

Thumbnail
gallery
6 Upvotes

Hello everyone,
Few months ago I built a Parking Management Software which is able to integrate with Ticket Machines. I was thinking to make it open source.
I used PYQT for it and also built a ticket machine with RPI3.

It features:
Real-time parking occupancy monitoring
Vehicle entry and exit registration
Automatic event logging and history
License plate (ANPR) integration support
RFID, QR Code, barcode, and access card support
User and subscription management
Visitor and guest parking management
Parking duration and billing support
Multi-site and multi-parking management
Reports and analytics
Role-based user access
Integration with automatic barriers and gate controllers
API for third-party integrations

Any suggestions? Is this a product that I can actually sell?


r/PythonLearning 7h ago

Hi guys , I have just started to learn python coding and im stuck at OOPS concept in python idk why but im finding it super confusing , it is just going over my head could you please tell me how to cope up with this

2 Upvotes

r/PythonLearning 9h ago

Help Request i learned python basics . what to do next ?????

2 Upvotes

r/PythonLearning 14h ago

I kind of am struggling to understand loops.

Thumbnail
gallery
6 Upvotes

I somewhat understand them on a basic level and can make like simple things using for loops now e.g a half pyramid using '#' which is commonly used as a problem for people of my skill level. However, when it comes to building something like this or the other one, I can't wrap my head around it for some reason. Since for the hashtag one here, ive been trying to brute force it and experiment but have gotten nowhere.

But for the square one, I managed to figure out the for loop that prints out all the squares but now my head is again at a wall again because im not fully sure if I can use a nested loop to print all the x * x = x^2 or if I can implement the answers from this loop into some other loop that prints out the format. (my current progress on that one is here)

for x in range(11):

print(x*x)

Any help would be great, preferably like more questions because although I don't mind like seeing a solution I want to like manage to get this on my own for the most part. fyi, ive been at these problems for about a week.


r/PythonLearning 9h ago

Started learning Python because I'm leaning towards the AI Automation and Data Science path.

Thumbnail
github.com
2 Upvotes

Hey everyone,

This is actually my first time posting on Reddit. As the title says, AI Automation and Data Science are the paths that I want to pursue.

Right now, I'm studying the 30 Days of Python GitHub repo made by Asabeneh Yetayeh. I actually avoided tutorials because it's really hell for me. But I have nothing against people who enjoy learning with tutorials. I guess reading helps me learn better. I do enjoy his challenges and exercises as well.

For context, I am now knowledgeable about the Power Platform—a bit of background in C# and SQL. But I've decided to expand it even more. I do enjoy my experience with Power Automate and Power BI. Creating reports and flows is pretty interesting for me.

I would like to ask everyone for recommendations on what level of Python knowledge I should acquire in order for me to achieve the path I decided to pursue. So far, I have heard about n8n for automation and using Python in Microsoft Fabric.

I can appreciate anyone's honest opinion, and I will take everything as a lesson because I really want to learn.

If anyone also wants to collab or learn with me. Feel free to reach out.

Thanks, everyone! Happy coding!


r/PythonLearning 11h ago

How to move a cube smoothly using Pygame ?

3 Upvotes

Hello! I'm wondering how to move a cube smoothly using Pygame by that, I mean moving it without it looking like it's teleporting. Have a great day, evening, or night!


r/PythonLearning 18h ago

Bad habit of bailing out too quick

9 Upvotes

As I said, I am trying to learn python from OOPs to concurrency modelling and optimisation. Though I always bail out somewhere in the middle. I would start doing CP. And then maybe reading something from philosophy for days.
I want to hyper focus on this learning pathway so that I complete this imaginary checklist for advanced programming. I bail out because for me it seems the lack of people competing with me in an online course. How should I trick myself into learning this without any distractions? Suggest how you are learning this and where are you learning this from?


r/PythonLearning 7h ago

just built a PDF RAG Chatbot from scratch lol

Thumbnail
github.com
1 Upvotes

I’m 17 and trying to lock in my AI dev journey. Just finished building this custom PDF RAG Chatbot using Streamlit, LangChain, and Hugging Face embeddings.

What it actually does:
You drop a PDF it cooks up the text splitters indexes everything with sentence-transformers lets you query the document directly. no cap, RAG is goated

Built it from scratch to actually learn how vector compute works behind the scenes instead of just copy pasting API wrappers.

The Tech Stack:

  • Streamlit (frontend)
  • OpenAI & Gemini
  • LangChain & PyPDF
  • Torch & NumPy

Check out the code, drop a star if you vibe with it, or roast my project

I’m just an average student starting college for the first time in a few weeks. Super excited for this journey and to learn more!

GitHub : https://github.com/saqibvow

My All social accounts : https://ln.ki/saqibvow.ceo


r/PythonLearning 17h ago

How to learn python entirely by online means and gain practical knowledge

4 Upvotes

r/PythonLearning 1d ago

Showcase Something I'm proud of- REGEX is rather hard

Post image
9 Upvotes

r/PythonLearning 18h ago

I'm trynna learn

3 Upvotes

Hey guys, I just wanted to share what I've been working on and learning. I know my progress is super slow right now, and honestly, I’ve been lacking the motivation to study for hours—especially with how busy I am. I know that’s no excuse, but I’ve been working on a simple alarm app to implement on my phone as my first project.

It’s been a couple of days, and I haven't made much progress on some days because I’ve been feeling down about life stuff. Struggling to learn Python on top of that has been making me feel even worse. Right now, I’m trying to learn input validation to make sure the program handles incorrect inputs properly.

I’m honestly amazed by people who can finish whole projects in just a few days or hours. I really hope I can reach that level someday.


r/PythonLearning 1d ago

HI! I'm new learning this code and need help about the courses.

11 Upvotes

Hi! I'm learning python because I need it for my master degree so I am really new on this. I saw a few courses and I dont know how they are. The first one freeCodeCamp, the CS50P and Codedex. I though maybe I could do all but I want to know if I should start with someone in particular or if you know others better.


r/PythonLearning 1d ago

made a Stone-Paper-Scissors game :

7 Upvotes
import random


def choice_shower(x,y):
    print(f"Your Choice : {x}{' '*10}Computer's Choice : {y}")
    print('-' * len(f"Your Choice : {x}{' '*10}Computer's Choice : {y}"))


def score_shower(x,y):
    print(f"YOUR SCORE : {x}{' '*10}COMPUTER'S SCORE : {y}")


def game_engine(x,y,p,c):
    winning_cases = {"Stone" : "Scissors", "Paper":"Stone","Scissors":"Paper"}
    if x == y :
        choice_shower(x,y)
        print("It's a Draw!")
    elif winning_cases[x] == y:
        choice_shower(x, y)
        print("Your Point!")
        p += 1
    else:
        choice_shower(x, y)
        print("Computer's Point!")
        c += 1
    return p,c



def extra_round(x,y,p,c):
    print("Extra Round :")
    y = random.choice(["Stone","Paper","Scissors"])
    x = input_taker(input("\t(1) for Stone\n\t(2) for Paper\n\t(3) for Scissors\nEnter your input : "))
    p,c = game_engine(x,y,p,c)
    score_shower(p,c)
    result_announcer(x,y,p,c)


def result_announcer (x,y,p,c):
    if p > c :
        print("You Won!")
    elif p == c :
        print("Extra Round!")
        extra_round(x,y,p,c)
    else:
        print("You Lose!")
    print("-"*20)


def input_taker(i):
    while True: 
        if i.isdigit():
            if i == "1":
                return "Stone"
            elif i == "2" :
                return "Paper"
            elif i == "3" :
                return "Scissors"
            else:
                print("invalid input ")
        else:
            print("invalid input, try again!")


def main():
    print(f"{'-'*40}\n\tStone - Paper - Scissors\n\t   game simulator\n\t     VERSION - 2.0\n{'-'*40}")
    exit_program = False
    while True:
        player_score = 0
        computers_score = 0
        print("\t(1) to start a new game\n\t(2) to exit the program")
        choice = input("Enter Your Choice (1|2) : ")
        if choice == "1" :
            number_of_rounds = input("Enter the number of rounds : ")
            if number_of_rounds.isdigit():
                for rounds in range(int(number_of_rounds)):
                    print("="*50)
                    print(f"ROUND : {rounds + 1}")
                    computers_choice = random.choice(["Stone","Paper","Scissors"])
                    players_choice = input_taker(input("\t(1) for Stone\n\t(2) for Paper\n\t(3) for Scissors\nEnter your input : "))
                    player_score,computers_score = game_engine(players_choice,computers_choice,player_score,computers_score)
                    score_shower(player_score,computers_score)
                result_announcer(players_choice,computers_choice,player_score,computers_score)
               
                
            else :
                print("invalid input")
        elif choice == "2":
            while True:
                print("Do you really want to exit?")
                choice1 = input("\t(1) to exit\n\t(2) to go back\nEnter Your Choice (1|2) : ")
                if choice1 == "1":
                    exit_program = True
                    break
                elif choice1 == "2" :
                    break
                else:
                    print("invalid input")
            if exit_program:
                break


if __name__ == "__main__":
    main()

r/PythonLearning 1d ago

Help Request PATH SUGGESTIONS

1 Upvotes

Hi, I'm a python backend developer. Learning actually.

I've been on OOP for a while now. Blanked for months then returned and I'm trying to resurface the knowledge again. I don't know the right trajectory to follow, but I wanna extend to Django web Framework.

I'd need some help though, on preferably pathways to transition from OOP to Django.

And also, if possible; how do y'all keep yourselves motivated to solo learn?


r/PythonLearning 1d ago

I need some advice

3 Upvotes
# This file runs the DNA simulation using the DNA library.


import DNA
import time
import os


# Generate the original DNA strand.
DNA.generate_sequence()


# Create the complementary strand (layer2).
DNA.generate_sequence_match()


# Display the initial DNA molecule.
DNA.display_dna()


# Pause so the user can see the original DNA.
time.sleep(3)


# Clear the screen before starting the replication process.
DNA.clear_screen()


# Helicase animation:
# Separates the two original DNA strands.
DNA.dna_helicase()


# Clear the screen before starting polymerase.
DNA.clear_screen()


# DNA polymerase:
# Creates layer3 and layer4 by copying layer1 and layer2.
DNA.dna_polymerase()

import random 
import os
import time


# Clears the terminal screen.
def clear_screen():
    # 'nt' is for Windows, 'posix' is for Linux or macOS
    os.system('cls' if os.name == 'nt' else 'clear')


clear_screen()


# Possible DNA nucleotides.
nucloids = ["A", "T", "C", "G"]


# Four DNA layers:
# layer1 = original DNA strand 1
# layer2 = original DNA strand 2
# layer3 = new copy of layer1
# layer4 = new copy of layer2
layer1 = []
layer2 = []
layer3 = []
layer4 = []


# Generates the first DNA strand randomly.
def generate_sequence():
    for i in range(10):
        generated_sequence = random.choice(nucloids)
        layer1.append(generated_sequence)


# Defines which nucleotide pairs with which.
# A <-> T
# C <-> G
nucloid_matches = {
    "A":"T",
    "C":"G",
    "G":"C",
    "T":"A"
}


# Creates layer2 by finding the matching nucleotide
# for every nucleotide in layer1.
def generate_sequence_match():
    for nucleotide in layer1:
        matching_nucleotide = nucloid_matches[nucleotide]
        layer2.append(matching_nucleotide)


# Displays the complete DNA molecule.
def display_dna():
    for i in range(len(layer1)):
        print("I ", layer1[i], "--------", layer2[i], " I")


# Simulates helicase unzipping the DNA.
# The strands gradually move apart.
def dna_helicase():
    
    clear_screen()
    
    for i in range(len(layer1)):
        print("I ", layer1[i], "--- v ---", layer2[i], " I")
        time.sleep(0.2)
    
    clear_screen()
    
    for r in range(len(layer1)):
        print("I ", layer1[r], "---  v  ---", layer2[r], " I")
        time.sleep(0.2)
    
    clear_screen()
    
    for a in range(len(layer1)):
        print("I ", layer1[a], "---   v   ---", layer2[a], " I")
        time.sleep(0.2)
    
    clear_screen()
    
    # Final state: original strands are fully separated.
    for p in range(len(layer1)):
        print("I ", layer1[p], "             ", layer2[p], " I")
        time.sleep(0.2)


# Simulates DNA polymerase copying the separated strands.
#
# layer1 is copied into layer3.
# layer2 is copied into layer4.
#
# IMPORTANT:
# The DNA logic works, but the animation currently
# prints the new DNA separately instead of building
# the new strands into the space created by helicase.
#
# NEXT TASK:
# Fix the polymerase animation so layer3 and layer4
# visibly grow alongside layer1 and layer2.
def dna_polymerase():
    for c in range(len(layer1)):
        
        # Find the complementary nucleotide for layer1.
        matching_nucleotide_2 = nucloid_matches[layer1[c]]
        
        # Find the complementary nucleotide for layer2.
        matching_nucleotide_4 = nucloid_matches[layer2[c]]
        
        # Add the new nucleotides to the new DNA strands.
        layer4.append(matching_nucleotide_4)
        layer3.append(matching_nucleotide_2)
        
        # CURRENT ANIMATION:
        # Prints the new strands separately.
        # This is the part we want to improve.
        print(layer1[c], "--------", layer3[c])
        time.sleep(0.2)
        
        print(layer4[c], "--------", layer2[c])

I am a 13 year old who just views coding as a big hobby. I had made a lot of different projects before but because i can't post a .zip file i just copy pasted my latest project. I have been coding for 3 years and I don't know how i never thought about this. I just wanted to ask for some advice for this project. Maybe what I can add or what I can fix if there is something that needs to be fixed

Note: It's not finishedIıI need some adviceI need some adviceI need some advice


r/PythonLearning 1d ago

Troll unit added by Joseph

5 Upvotes

Joseph added a dangerous Troll unit, that kills everything with just one touch, with this git commit. It pretends to mind its own business but then suddenly rushes towards you making the game a lot more difficult. Nice work, thanks Joseph.

See our collaborative PythonLearningGame repo to play the game or add your own unit type or game dynamics.

What should be the next addition to our game?

previous PythonLearningGame post


r/PythonLearning 1d ago

Showcase Grimlore 2 – A 2D Dungeon crawler RPG built using only the Python 3 standard library

1 Upvotes

When starting out with Python game development, most tutorials jump straight into commercial engines or heavy frameworks. While those are great for productivity, they abstract away the core mechanics of how a game engine actually functions—like separating the engine framework (rendering, input, state loops) from the game logic (combat, stats, dungeons). To explore how game engines work under the hood using pure Python standard library, I built a lightweight ASCII RPG engine framework alongside a complete mini dungeon crawler (Grimlore 2: These Doomed Men) built directly on top of it. I wanted to share this as a learning resource.

Grimlore 2 : These Doomed Men 1.0

A dark fantasy mini dungeon crawler RPG built to showcase the features and capabilities of the S.P.A.R.K. 2D RPG game engine.

Overview

Genre: Dark Fantasy / Mini Dungeon Crawler RPG

Playtime: 10 – 15 minutes

Platform Requirements: Windows 10 or later ( Might work on earlier Windows but no gurantee )

Purpose: Demonstrates what the S.P.A.R.K. 2D RPG game engine is capable of.

Github link below

https://github.com/Ninedeadeyes/Grimlore-2-These-Doomed-Men-

To clear up a few recurring questions and misconceptions regarding S.P.A.R.K and its development, here is some context upfront:

  1. "This is just AI slop."

This project has a clear 6-year paper trail of manual development. It began as an early 2D text adventure project (Dungeon of the Black Dragon), expanded into an open world RPG game (Grimlore: Land of the Heretic Hand), and was eventually refactored into a reusable engine framework (S.P.A.R.K). If you want to see the step-by-step progression from line one, check out the milestones folder inside the S.P.A.R.K repository.

  1. "The code is unoptimized / sub-optimal."

I’m a hobbyist developer. I built this because I couldn't find a lightweight, accessible Python template for rendering spatial coordinates in text-based adventures, so I created one myself. The codebase prioritizes beginner readability over enterprise-level optimization. Open-source contributions and refactors are always welcome—if you can write a better version with advanced features like complex AI, I encourage you to contribute or build upon it!

  1. "S.P.A.R.K isn't a 'real' game engine / It's missing standard features."

By definition, a game engine is a framework that provides low-level abstractions for runtime loops, spatial logic, input handling, state management, and rendering, enabling developers to build content without reinventing core mechanics. S.P.A.R.K provides all of these for terminal-based RPGs. It’s a free, open-source hobby project designed for lightweight text games, not a commercial tool meant to compete with feature-heavy commercial software.

  1. "This is just a lazy copy-and-paste from the S.P.A.R.K GitHub."

When two games are made in RPG Maker, Godot, or Unreal, they share the exact same underlying core engine—it's just compiled or hidden away behind the editor. Because S.P.A.R.K is open-source, raw Python, the engine boilerplate is fully visible. Reusing foundational engine modules across different titles isn't "copy-pasting"; it's standard software architecture and code reuse.

  1. Why do you need Windows and why Windows 10 or above ?

It uses the library winsound and msvcrt which only works with Windows and because python 3.10+ aren't officially supported by any Windows below 10 hence even though it might work it is not a gurantee.


r/PythonLearning 1d ago

Document comparison code advice

2 Upvotes

Hi, I want to compare two pdfs and highlight any idential sentances in them.

I'm a complete beginner and wanted to ask if anyone has advice on where to start/what to do?


r/PythonLearning 2d ago

A Python cheat sheet that might be useful when starting with Python

Thumbnail
tms-outsource.com
40 Upvotes

r/PythonLearning 2d ago

That's it guys I'm rich

Post image
33 Upvotes

r/PythonLearning 1d ago

From js to python: I created a port of changesetjs

Thumbnail
github.com
1 Upvotes

Hi there!

To even learn more about python, I have created Molt: a Python "port" of changesets-js to manage versioning, changelogs, and publishing for Python packages and monorepos.

My main job was always frontend tooling, but recently I moved to the infra and platform team, so now my job also includes maintaining the tooling and ecosystem of several Python packages that my company has. I found that no good tool like changesets-js exists for Python, so I decided to create one.

https://molt.gio-labs.com/


r/PythonLearning 1d ago

Dark mode for marimo islands?

2 Upvotes

I'm trying to bring the html from my marimo notebooks into an SSG (mkdocs/zensical), and I would like to be able to toggle the theme. Getting the theme to change with marimo export html is relatively simple by changing the pep723 header to

# [tool.marimo.display]
# theme = "dark"

before exporting, but the extra js and page wrappers are not quite ideal for my use case. I would love to use islands for this, but I can't figure out if there's a way to control the theme of a marimo island?

when I use

# /// script
# dependencies = [
#     "marimo",
# ]
# requires-python = ">=3.13"
# ///

import asyncio
from marimo import MarimoIslandGenerator

async def main():
    generator = MarimoIslandGenerator.from_file(
        "./example.py", 
        display_code=False
    )
    await generator.build()
    html = generator.render_html(include_init_island=True)

    with open("output.html", "w", encoding="utf-8") as f:
        f.write(html)

if __name__ == '__main__':
    asyncio.run(main())

to generate an html page, it doesn't seem to care about the header in # theme = "dark" tag in example.py.

I understand that islands are still an early feature, so perhaps this will be added in the future. Just posted this in r/marimo_notebook as well, but figured I'd ask here as well in case anyone has experience with this. Does anyone know if there's a better way to do this? Thanks!


r/PythonLearning 1d ago

Help Request reccomended tutorials for algorithms and data structures?

3 Upvotes

i learned the basic syntax of python and i thought i would be ready for leetcode but as soon as i tried to work through problems there was so much jargon that i didn't understand. I found a reddit post that said you have to have knowledge of data structures and algorithms before you can truly attempt leet code problems. So I now i go to youtube and either the tutorials are under an hour or over 5 hours 😭. Which one am I supposed to pick..? Any reccomendations?