r/PythonLearning • • 3d ago

Python Quiz of the day

7 Upvotes

What will be the output of the following Python Code?

a = 5

print(a.mul(3).add(2))


r/PythonLearning • • 2d ago

built a full multi-user CRM using zero third-party dependencies, thoughts?

0 Upvotes

I challenged myself to build a production-ready, multi-user CRM for small agencies using strictly the Python 3.9+ standard library; zero pip packages, zero frameworks, and zero frontend build steps.

49 Second Walkthrough: https://www.loom.com/share/ee9b8507bf6c4811b6f2b6b267e90547

A few interesting standard-library implementation details:

Auth & Security: Password hashing with hashlib.scrypt + per-user random salts and hmac.compare_digest, account lockout after failed attempts, and RFC-compliant TOTP 2FA + backup codes written with hmac, struct, and time.

Database Layer: Raw sqlite3 running in WAL mode with foreign keys enforced, integer-cent currency storage (value_cents) using decimal.Decimal to avoid float rounding bugs, automated schema migrations via PRAGMA table_info, and a 200-row audit trail.

CRM Features: Multi-pipeline Kanban boards, stage-duration tracking (stage_at) to flag stale deals, duplicate contact merging, CSV import/export, role/field-level visibility masking (HIDEABLE fields), outbound webhooks, and automated daily .db backups.

Would love feedback from other Python devs on what else you'd expect in a zero-dependency internal tool!

Thank you ahead, for your time!


r/PythonLearning • • 2d ago

Help Request Can't remove specific text in txt file.

1 Upvotes
rom tkinter import *


def add_product():
    new_product = name_entry.get()
    with open("list of products.txt", "a") as file:
        new_product_name = name_entry.get()
        new_product_ID = id_entry.get()
        new_product_category = category_entry.get()
        new_product_price = price_entry.get()
        new_product_quantity = quantity_entry.get()
        new_product_expiry = expiry_entry.get()
        file.write(f"{new_product_name}\n")
        name_entry.delete(0, END)
        id_entry.delete(0, END)
        category_entry.delete(0, END)
        price_entry.delete(0, END)
        quantity_entry.delete(0, END)
        expiry_entry.delete(0, END)


def remove_product():
    name_data = name_entry.get()
    id_data = id_entry.get()
    category_data = category_entry.get()
    price_data = price_entry.get()
    quantity_data = quantity_entry.get()
    expiry_data = expiry_entry.get()
    with open("list of products.txt", "r") as file:
        products = file.readlines()
    with open("list of products.txt", "w") as file:
        for line in products:
            print(line)
            name = line
            if name != name_data.strip():
                file.write(name)

everytime i try to enter a product "apple" to delete, it will never be deleted from the "list of products.txt"

this is what is included inside products.exe:
apple
pear
pineapple

r/PythonLearning • • 3d ago

Discussion How do you handle files with unknown or incorrect extensions in Python?

6 Upvotes

I was wondering if there's a Python package that can identify and read different file formats without having to specify the extension every time.

For example, if I receive a file without a proper extension or with an incorrect extension, can Python figure out whether it's CSV, Excel, JSON, Parquet, etc., and read it automatically?

I know there are libraries for individual formats, but I'm curious if there's something that can handle multiple formats intelligently.

Has anyone worked on something similar or found a reliable approach for this?


r/PythonLearning • • 3d ago

I built a website to learn and practice Python directly in the browser

30 Upvotes

Hello everyone,

I’ve been working runtime.school for a while now to help people learn Python by actually writing code.

It has interactive lessons that explain concepts with examples, followed by coding challenges to try things yourself. It has practice questions, projects, and datasets to work with as you progress.

Everything runs in the browser, so you don’t need to install Python or set anything up.

I’ve tried to keep the lessons beginner friendly and make sure the practice questions follow what you’ve learned rather than jumping into random topics.

It’s free to use: https://www.runtime.school/python

Would love to hear what you think, especially if you’re just starting out or getting back into Python after a while.


r/PythonLearning • • 3d ago

Help Request Problem with pygame not responding

2 Upvotes

Hello, I am relatively new to python and am trying to learn pygame. I am attempting to make a game where you have to guess the song and I'm playing the mp3 with the pygame mixer. Before I added the song, it just opened a window with colored background and some text. When I put in the music it plays normally, I can pause it and resume it via terminal, however the window that was opening before now shows black and isn't responding. I have no idea what is causing this and can't find anything on the internet. Does anyone know whats happening?

Here is the code:

#load and initialize
import pygame
pygame.init()
pygame.mixer.init()


#window info
displayw = 640
displayh = 550
screen = pygame.display.set_mode((displayw,displayh))
title = pygame.display.set_caption("game")


#clock
clock = pygame.time.Clock()


file = "song.mp3"
pygame.mixer.music.load(file)
pygame.mixer.music.set_volume(0.7)
pygame.mixer.music.play()



class MainRun(object):
    def __init__(self,displayw,displayh):
        self.dw = displayw
        self.dh = displayh
        self.Main()


    def Main(self):
        running = True
        font = pygame.font.Font(None, size = 45)
        text = font.render("text", True, (200,200,200))


        while running:
            screen.fill((60,21,70))


            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    quit()
                elif event.type == pygame.KEYDOWN:
                    running = False


            print("Press 'p' to pause, 'r' to resume")
            print("Press 'e' to exit the program")
            userinput = input("  ")
            
            if userinput == 'p':
                pygame.mixer.music.pause()     
            elif userinput == 'r':
                pygame.mixer.music.unpause()
            elif userinput == 'e':
                pygame.mixer.music.stop()
                break


            screen.blit(text, (195,100))


            pygame.display.flip()
            clock.tick(60)


if __name__ == '__main__':
    MainRun(displayw,displayh)

r/PythonLearning • • 3d ago

Showcase I made my first big python game

Thumbnail pz.run
2 Upvotes

I have been coding in python for some months and its abt time i made my first game, I'm still fixing the instructions option as that has some made up features that I was abt to add.

So... wut u basically have to do is find both stuctures with exploring, bith of those structures contain the key items u need for escaping the island. Ts is the link to it, plzzz gimme sum feeback, also i used claude for finding bugs

I named it Survival_island


r/PythonLearning • • 3d ago

Help Request Problem with pygame not responding

2 Upvotes

Hello!
I am relatively new to python and am trying to learn pygame. I am attempting to make a game where you have to guess the song and I'm playing the mp3 with the pygame mixer. Before I added the song, it just opened a window with colored background and some text. After that when I put in the music it plays normally, I can pause it and resume it via terminal, however the window that was opening before now shows black and isn't responding. I have no idea what is causing this and can't find anything on the internet. Does anyone know whats happening?

Here is the code:

#load and initialize
import pygame
pygame.init()
pygame.mixer.init()


#window info
displayw = 640
displayh = 550
screen = pygame.display.set_mode((displayw,displayh))
title = pygame.display.set_caption("game")


#clock
clock = pygame.time.Clock()


file = "song.mp3"
pygame.mixer.music.load(file)
pygame.mixer.music.set_volume(0.7)
pygame.mixer.music.play()



class MainRun(object):
    def __init__(self,displayw,displayh):
        self.dw = displayw
        self.dh = displayh
        self.Main()


    def Main(self):
        running = True
        font = pygame.font.Font(None, size = 45)
        text = font.render("text", True, (200,200,200))


        while running:
            screen.fill((60,21,70))


            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    quit()
                elif event.type == pygame.KEYDOWN:
                    running = False


            print("Press 'p' to pause, 'r' to resume")
            print("Press 'e' to exit the program")
            userinput = input("  ")
            
            if userinput == 'p':
                pygame.mixer.music.pause()     
            elif userinput == 'r':
                pygame.mixer.music.unpause()
            elif userinput == 'e':
                pygame.mixer.music.stop()
                break


            screen.blit(text, (195,100))


            pygame.display.flip()
            clock.tick(60)


if __name__ == '__main__':
    MainRun(displayw,displayh)

r/PythonLearning • • 4d ago

Showcase I JUST finished my second python project!

Post image
218 Upvotes

Lately I have been working on this ATM For Teens, just to understand OOP and some concepts more (which I REALLY DID)

this isn't meant to be a real ATM (obviously, it's very beginner and not security is there), here is my First project.

So, I have learnt quite a lot since last project, I learnt a bit more about python syntax, I also understood the approach of classes a lot better. I learnt git (just the essentials).

Since I always wanted to Make iPhone apps, and now I have a Mac, I'm thinking whether I should start learning swift and swiftUI, or move to something else, or keep learning python. what do you guys think? I Do want a job as an IT engineer (or anything with coding tbh, cybersec too but that would require C knowledge a bit more lol)

Otherwise, if you guys have any criticism or suggestions for the ATM, then I would be veryyy happy to hear some! here's the repo: https://github.com/Stonyax97/ATM-For-Teens


r/PythonLearning • • 4d ago

I am 14 and I need a advise is it ok to learn Python from phone and with chatGPT

5 Upvotes

learned: Variables and print() User input and type conversion If, elif, else statements Arithmetic and comparison operators For and while loops Range() Lists and indexing append(), remove(), pop(), len() I've also started building a simple Shopping List App using Python. I can solve basic exercises, but I'm still learning how to combine concepts and build applications independently. I currently dedicate around 2 hours a day to learning.


r/PythonLearning • • 3d ago

Showcase spgpy v2.0.0 released - A refactored Python library for secure password generation

0 Upvotes

Hi everyone,

I've just pushed v2.0.0 of spgpy, an open-source Python tool for generating and validating passwords.

GitHub Repository & Full Changelog: https://github.com/toncotales/spgpy

Feedback and contributions are welcome!


r/PythonLearning • • 4d ago

Python Quiz of the day.

0 Upvotes

What will be the output of the following Python Code?

a, b = zip(*[(1, 2), (3, 4), (5, 6)])

print(sum(a) - sum(b))


r/PythonLearning • • 4d ago

Discussion DataCamp Black Friday Sale 2026

Thumbnail
pythoncoursesonline.com
2 Upvotes

r/PythonLearning • • 3d ago

Showcase byte strings

0 Upvotes

I found it abit annoying and confusing to represent "some bytes" with ASCII letters. I don't know why python chooses to do so for Unicode characters less than 127. Anyway I wrote my own implementation for UTF-8. Here is the implementation:

string = '😂happy man'
byte_list = []

for char in string:
    binary_string_list = list(f'{ord(char):b}')
    binary_string_list.reverse()
    
    # check length of binary_string
    if len(binary_string_list) <= 7:
        # data represented using a single byte.
        byte_temp = list('0???????')
        byte_temp.reverse()
    
    elif len(binary_string_list) <= 11:
        # data represented using two bytes.
        byte_temp = list('110?????10??????')
        byte_temp.reverse()
        
    elif len(binary_string_list) <= 16:
        # data represented using two bytes.
        byte_temp = list('1110????10??????10??????')
        byte_temp.reverse()
        
    elif len(binary_string_list) <= 21:
        # data represented using two bytes.
        byte_temp = list('11110???10??????10??????10??????')
        byte_temp.reverse()
    
    def imlement_utf(byte_temp, byte_string_list):
        # this function fills the byte templates with actual binary data
        if '?' in byte_temp:
            for bit in byte_string_list:
                byte_temp[byte_temp.index('?')] = bit
                    
            byte_temp.reverse()
            
            for bit in byte_temp:
                if bit == '?':
                    byte_temp[byte_temp.index('?')] = '0'
        
        global byte_list             
        byte_list += byte_temp
    imlement_utf(byte_temp, binary_string_list)

print(f"This is the encoded binary string: {''.join(byte_list)}")
print()
# converting binary string to byte string:
hex_string = ''
f_hex_string = ''
data = ''.join(byte_list)
offsets = zip(range(0, len(data)-7, 8), range(8, len(data)+1, 8))
for x, y in offsets:
    byte = data[x:y]
    # binary to decimal
    byte = int(byte, base=2)
    # decimal to hexadecimal
    byte = f'{byte:x}'
    hex_string += ' '+byte
    # formatted hexadecimal
    f_hex_string += '\\x'+byte
print(f'This is the condensed binary string in hexadecimal: {hex_string.strip()}')
print()

print(f"This is the formarted hexadecimal string (byte string):b'{f_hex_string}'")
print()

print(f"This is the byte string python returns: {bytes.fromhex(hex_string)}")

r/PythonLearning • • 4d ago

I'm 14 and I started to learn python programming any Guidance

3 Upvotes

So far, I've learned: Variables and print() User input and type conversion If, elif, else statements Arithmetic and comparison operators For and while loops Range() Lists and indexing append(), remove(), pop(), len() I've also started building a simple Shopping List App using Python. I can solve basic exercises, but I'm still learning how to combine concepts and build applications independently. I currently dedicate around 2 hours a day to learning. I'd like your honest opinion: What level would you consider me at: beginner or early intermediate? What should I learn next? What mistakes should I avoid as a beginner? How can I progress towards building real-world applications and eventually AI projects? I'm not looking for fake motivation. I'd appreciate honest, practical advice. Thanks!


r/PythonLearning • • 5d ago

Help Request Socket Chat (small chat app in plain Python)

17 Upvotes

Hello 👋

I made this is a small desktop chat app written in plain Python, with TLS sockets, a Tkinter client and SQLite storage. You sign up, add friends and message each other

I built it as a learning project and still work on it for fun: https://github.com/ABuljko/socket-chat

I’m open to advice on what to do next since I am getting to the point where I am getting stuck on it


r/PythonLearning • • 5d ago

Help Request How does this work?

4 Upvotes
def remove_inventory():
    remove_name = item_name_entry.get()
    with open('inventory.txt', 'r') as file:
        inventory_data = file.readlines()
    with open('inventory.txt', 'w') as file:
        for line in inventory_data:
            name, qty = line.strip().split(',')
            if name != remove_name:
                file.write(line)
    item_name_entry.delete(0, tk.END)
    item_qty_entry.delete(0, tk.END)

hello guys, this is one of the sample code of inventory manager, there is one line of code im confused with. Im not really sure how does the "name, qty = line.strip().split(",") work, specifically the "name, qty=" part. Im guessing the "qty" is the variable but what does "name," do?


r/PythonLearning • • 4d ago

What the 3 Numbers in a Python Version Mean?

2 Upvotes

Python versions have three numbers, like 3.15.2. Here's what each one means and which one you actually choose.

3 = major version (always 3 for this course)
15 = feature release, the one you choose
2 = micro release, bug fixes and security fixes

▶️ Full lesson (Which Python should you install?)
📚 Free Python course playlist

Youtube: Amir Zare Dev

🎵 Music: "Misdirection" – The Grey Room / Density & Time (YouTube Audio Library)

#Python #LearnPython #PythonForBeginners


r/PythonLearning • • 5d ago

Help Request what is the error i don't get it

Post image
93 Upvotes

r/PythonLearning • • 5d ago

Help Request Why does changing one list also change the other?

1 Upvotes

I'm working through lists and variables in my intro course and ran into something I don't understand. I thought assigning a list to a new variable would make a separate copy, but changing one of them seems to change both.

Here's a minimal version:

original = [1, 2, 3]
copy_of_it = original
copy_of_it.append(4)

print("original:", original)
print("copy_of_it:", copy_of_it)
print(original is copy_of_it)

Output:

original: [1, 2, 3, 4]
copy_of_it: [1, 2, 3, 4]
True

I expected original to stay [1, 2, 3] since I only added 4 to copy_of_it. I've printed id() of both variables and they match, and I skimmed the docs section on mutable objects, but I still don't get why they're linked. Could someone explain what's happening under the hood?


r/PythonLearning • • 6d ago

Giving back to the community - The Complete Backend Development Course (last round)

38 Upvotes

Hey everyone, I decided to make my course free in order to help people.
This course is my backend development course which is about SQL, Python, APIs, Docker, Kubernetes, Linux, Git & More

The link is: https://www.youtube.com/watch?v=CBIu6hcyStg

If you can like and subscribe (and maybe add a comment) I would appreciate it a lot, Thanks.


r/PythonLearning • • 5d ago

Python interview questions: 10 with answers

Thumbnail
opnf.sh
1 Upvotes

10 Python interview questions with sample answers and tested code, from mutable defaults and is vs == to the GIL, plus how to explain them out loud.


r/PythonLearning • • 5d ago

Help Request What’s the best tutorial for learning Python?

0 Upvotes

I did some Java programming before- not an expert though


r/PythonLearning • • 5d ago

Showcase I built a Python tool that tracks my coding time on Windows without a start/stop timer

Thumbnail
gallery
3 Upvotes

I wanted to know how much time I actually spend in my IDE. Leaving PyCharm open all afternoon doesn’t mean I coded for four hours, so I wrote a small Python tracker that runs in the background. It checks which window is in focus and pauses after 10 minutes of inactivity.

The first version sent daily totals to the Pixela API. For this version, I built a local dashboard with PySide6 and Matplotlib. I can open it at the end of the week, see my hours day by day, and compare them against a daily goal. The data stays on my PC, and the dashboard can stay closed while the tracker runs.

It tracks PyCharm, VS Code, Visual Studio, and IntelliJ IDEA by default. If you use another editor, you can add its .exe name to a JSON file. There’s also a demo mode if you want to try the dashboard before you’ve logged any time.

GitHub: Coding Tracker Dashboard

One trade-off I’m curious about: reading docs in a browser is often part of coding, but the tracker only counts time in the apps you choose. If you tracked your own coding time, would you want to include that, or would you find an IDE-only total more useful?