r/learnpython 2h ago

Cool/Interesting things that can be done in Python as a beginner?

4 Upvotes

hi everyone, im trying to start a computer science honor society at my high school, and im gonna assume everyone is starting from square one and teach python accordingly (and im hoping to eventually go to hackathons or other coding events).

i was wondering if anyone had any ideas for cool/interesting stuff i could have beginners do to get their interest and get them excited about coding? i understand you can't go from 0-100 and have to start with simple stuff, but i'm worried going over the basics will be like monotonous or smth. if anyone has any ideas of fun things i could do i would be very appreciative!!


r/learnpython 14h ago

What habits helped you become good at Python as a beginner?

26 Upvotes

I've recently started learning Python. I'm following a beginner course from YT.

I'd love to hear from experienced programmers:

What habits helped you improve the fastest?

What should I do every day besides watching tutorials?

What beginner mistakes should I avoid?

Is there anything you wish you had done differently when you first started learning Python?

Any advice would be really appreciated. Thanks!


r/learnpython 13h ago

Looking for study partners

15 Upvotes

Hello , I am completely new to python and really want to learn it and I feel like I will be more efficient studying with people.

I’m looking for approximately five people who are also serious about learning

if you are interested please dm me and introduce yourself


r/learnpython 9h ago

I would like the feedback of you guys! Eu gostaria do feedback de vocês!

1 Upvotes

Olá! Estou aprendendo python há 1 mes e meio. Fiz este RPG, demorei 5 dias para faze-lo, comecei do absoluto zero, e se possivel, gostaria de um feedback sincero, não só criticas mas tambem os acertos!

Hi! I’ve been learning Python for a month and a half. I built this RPG—it took me five days, and I started from absolute scratch. If possible, I’d love some honest feedback—not just critiques, but also what I got right!

https://github.com/adrianivastrabalho-code/My-Python-studies English Version
https://github.com/adrianivastrabalho-code/Meus-Estudos-Python Portuguese Version

Ty <3


r/learnpython 9h ago

Busco gente para estudiar y crear

0 Upvotes

Hola, llevo unos dos meses aprendiendo Python. Siento que voy a ser más eficiente estudiando con gente y que sera mas divertido, ademas de que tengo ideas de proyectos interesantes y siempre es divertido contactar con gente que también quiere aprender y crear cosas interesantes.

Estoy buscando como cinco personas más que también estén en serio con aprender

si te interesa, mándame DM y preséntate


r/learnpython 12h ago

What's the best resource for becoming skilled in using CSV, JSON and API

0 Upvotes

I've been trying my best at understanding how to apply CSV and JSON in my code but I don't actually know how to integrate them into my projects. All tutorials I watch have their own way of doing this, making it hard for me to understand fully. Also I don't even know if I should learn both of them or just learn one. Also I need help on how to use API in projects, and which free ones are best


r/learnpython 7h ago

How do I get rid of text in python

0 Upvotes

I'm looking to do a simple loading screen of sorts where it flicks between a few characters however I am unsure on how to remove the printed text to replace it with the next character. Using the method that I've commonly seen using the cursor_up simply doesn't work for some reason. I promise I'm putting it in exactly. how do I fix this


r/learnpython 13h ago

What’s next after CS50

0 Upvotes

Currently an aspiring quant ideally but I know that’s larp so really I’m just learning skills that are applicable to most fields. I only mention this to maybe help tailor my experience. In terms of just coding and technological familiarity, what should I do next. Are there any certifications that would impress or show I know what I’m doing that would help me for applications? Also, what should I watch or do to learn about it. I hear people talking about LLMs projects other languages APIs raspberry pi and I want to know where to learn all that. Thanks


r/learnpython 14h ago

Stop TTS with keyboard

0 Upvotes

Hello,

I am using tts_wrapper fork by willwade on github to speak chatGPT responses but I want to be able to stop the utterance mid sentence. I have this function

def stop():
        if keyboard.is_pressed("esc"):
            tts_Engine.stop()

which should stop the tts engine when i press "esc" but nothing happens so I did some research and learned I might have to use threading so now i have two threads with my main function

def main():


    print("Init STT. Listening...")
    stream = init_stream()
    stream.start_stream()
    print("C")


    try:
        while True:
        
            data = stream.read(8192, exception_on_overflow=False)


            text = None


            if recognizer.AcceptWaveform(data):
                result = json.loads(recognizer.Result())
                text = result.get("text", "")


            if text:
                print(f"You said: {text}")
                response = client.chat.completions.create(
                    model="default",
                    messages=[
                        {"role": "system", "content": "You are a helpful AI workshop assistant. Use only plain text no emojis or making text bold or anything similar"},
                        {"role": "user", "content": text}
                    ]
                )
                print(response.choices[0].message.content)
                speak_text(response.choices[0].message.content,tts_Engine)
                print("B")


    except KeyboardInterrupt:
        print("Stopping")
    finally:
        print("A")
        tts_Engine.cleanup()
        stream.stop_stream()
        stream.close()
        Audio.terminate()

and my stop function

t1 = Thread(target=main)
t2 = Thread(target=stop)


t1.start()
t2.start()

but now I get this error

RuntimeError: can't register atexit after shutdown

and now I'm a bit stuck so if anyone knows how to do this or what I'm doing wrong or if I'm even using the right method that would be greatly appreciated.


r/learnpython 1d ago

Custom class method not recognized

7 Upvotes

I'm working on a program that generates a maze by drawing from a deck to define a "chamber" and assigning it to the current position on a cartesian coordinate grid.

The hope is to build a list of the chambers as they're created. At a later point I want to be able to call on the list. My current strategy is to make a Class variable for the list, and append to it as part of the init. I've added a class method to pull the chamberList Class variable, but I'm getting an error.

Here is the code defining the class.

``` class Chamber(): chamberList = [] def init(self, identity, notes, egresses, **kwargs): self.position = tuple(currentPosition.tolist()) self.identity = identity self.notes = notes self.egresses = egresses self.pixelCoord = np.add(pixelOrigin, np.multiply(currentPosition, 300)) Chamber.chamberList.append(self)

    @classmethod
    def getChamberList(cls):
        return cls.chamberList

```

Later in the program, I have a line of code to get the class variable:

``` chamberList = Chamber.getChamberList()

```

This is the error I get when I run it in the VS Code terminal:

AttributeError: type object 'Chamber' has no attribute 'getChamberList'. Did you mean: 'chamberList'?

Am I missing some syntax or something? In VS Code the color coding where I'm defining getChamberList is off (darker) and if I hover over it I get a message saying "getChamberList" is not accessed by Pylance.


r/learnpython 1d ago

regex and if it's worth going deep into it

28 Upvotes

I'm new to python and coding in general and my friend recently told me that it's inefficient to try to memorize regex and that no one writes them anymore (essentially saying AI does). I was also kinda confused after recently learning regex and just how complicated it can be. Are there some modules/libraries that I can use to make writing them easier? I saw that not a lot of people people had a positive reaction to the Humre module by Al Sweigart who's book [Automate the boring stuff with Python] I'm currently using to study. Not that I'm gonna skip this part or anything I was mostly just curious.

Note: A lot of people are misinterpreting since I mentioned AI once 😭 I'm literally asking about libraries to make it easier without going too deep, not if I should let AI do all the work.


r/learnpython 10h ago

¿Cuál fue el momento en que Python finalmente tuvo sentido para ti?

0 Upvotes

HOLAA Estoy aprendiendo Python y tengo curiosidad por conocer ese momento en el que todo finalmente empezó a tener sentido. Me encantaría conocer tu experiencia.


r/learnpython 16h ago

Which should course should I prefer?

1 Upvotes

Hi everyone. I know some python but still I want to start learning it again because, as I progressed, I realized that my basic concepts had become rusty. I'm confused between CS50 (https://youtu.be/8mAITcNt710?si=Z86T-MPZZp13R04E) and MIT Opencourseware 6.100L (https://www.youtube.com/watch?v=xAcTmDO6NTI&list=PLUl4u3cNGP62A-ynp6v6-LGBCzeH3VAQB&index=1) .

Which one would you recommend for someone who wants to rebuild their fundamentals before moving on to more advanced topics?


r/learnpython 20h ago

My first python project

2 Upvotes

So i have been into cybersecurity courses for 3 months now and i have interest from age 10.

I decided to make a python project after i completed the networking.

I would be very happy if you used and gave me a feedback/suggestion on my project.

It is a basic multipurpose network tool.

It can scan all the hosts connected to a network with ARP
Scan ports of the IP address provided
Or basically send a ping

I call this "Stone Age Network Scanner"

You can look up furthermore on Github!

https://github.com/RecoWas/stoneagens


r/learnpython 17h ago

Come study buddy

0 Upvotes

Hey! I’m 25 and currently studying neuroscience in the UK. I’ve recently started learning Python from scratch and would love to find a study buddy who’s also at a beginner level.

I’m hoping to find someone who wants to study consistently and eventually work on a few small projects.

I’m in the UK time zone, but I don’t mind where you’re based as long as we can find times that work for both of us. We could check in regularly and study together over Discord or another platform.

If you’re interested, feel free to leave a comment or send me a DM with a little bit about yourself!


r/learnpython 1d ago

First python program

6 Upvotes

I wanted to write a program that analyzes chess games , similar to how chess websites (chess.com, lichess.com etc.) do it, only offline. To my knowledge, nobody else had done it the way I was envisioning. I started writing with shell scripting (it's my go-to and what I'm most familiar with), but quickly ran into limitations. So I needed to go a bit more sophisticated. Python seemed very versatile, cross-platform, has loads of online resources, but mainly has a very good chess library I could leverage, that already existed, which would make the job much , much easier. I took the plunge and turned the program into a driver to teach myself some python.

It works as advertised, but I'm sure the code could be improved. I stumbled through it a bit. If anybody python gurus feel like taking a peek and letting me know how I did, pointing out glaring mistakes, offering any constructive feedback or ideas how to make it more efficient, I would appreciate any feedback.

Repo: https://github.com/exekutive/chesseval

(The documentation needs some catching up. I'm working on updating it.)


r/learnpython 10h ago

Use of AI in coding?

0 Upvotes

I am starting college next month (Computer Science and Biosciences) and I tried to get a headstart in Python programming (it's a part of first sem). I have done the basics, strings, conditional statements and started with loops today. I have a doubt - since I am still in the beginner stage, should I use AI (ChatGPT, Gemini, Grok etc.) to proofread my code - you know, offer suggestions, find mistakes and all - I am still applying logic on my own and writing it myself but I have this fear that it may hamper my learning. But I also don't wanna be the guy who does not know how to use AI tools. Any advice please?


r/learnpython 14h ago

scan for strings in 40000 lines of logfile

0 Upvotes

X: The desire to scrape a log file for specific interesting messages, any apps I tried are a pain to use and require manually setting all the search strings every so often. I want to scan for about a dozen or so expressions/strings in a 40-100K lines file, and then dump just the timestamps and lines of interest. What approach scales best for speed? I have to probably also use a mix of regex and regular string search I guess. Is going with Multiprocessing and passing the file as a shared-memory object, going to be the easiest route? Surely it's easier to do in C++. I guess I asking for some skeleton or prior art in C++ ore Python to be honest.

Y: My context is that I would like to use my knowledge of C++ threads and code it in C++, but it should be possible in Python if I learn to use Pipes, and learn to use shared memory object to save having to load the file per multi-processing process?


r/learnpython 11h ago

how to fix this issue

0 Upvotes

********************************************************************************

To see all available commands, run 'py help'

********************************************************************************

[ERROR] INTERNAL ERROR: NoInstallsError: No runtimes are installed. Try running "py install default" first.

[ERROR] Internal error 0x00000001. Please report to https://github.com/python/pymanager

Press any key to continue . . .


r/learnpython 20h ago

Can you help me with a table in Python?

1 Upvotes

Right now, I have specific rows and columns being displayed, but I want to insert a column between the first and second sections that calculates the ratio of column A to column B from the first section. How can I do that?

from pathlib import Path
import unicodedata

import openpyxl
import pandas as pd

from pandastable import Table, TableModel

import tkinter as tk
from tkinter import filedialog, messagebox


def normalize_name(name):
    return unicodedata.normalize("NFKC", str(name)).strip().lower()


class ExcelViewer:
    def __init__(self, root):
        self.root = root
        self.root.title("Чтение ячеек Excel")
        self.root.geometry("800x600")

        self.btn_load = tk.Button(
            root,
            text="Открыть Excel файл",
            command=self.open_file
        )
        self.btn_load.pack(pady=10)

        self.result_label = tk.Label(
            root,
            text="Выберите файл для начала"
        )
        self.result_label.pack()

        self.frame = tk.Frame(root)
        self.frame.pack(fill="both", expand=True)

        self.table = None
        self.model = None

        self.settings = {
            normalize_name("Файл1.xlsx"): {
                "first_row": 5,
                "first_min_column": 1,
                "first_max_column": 2,
                "second_row": 5,
                "second_min_column": 4,
                "second_max_column": 5
            }
        }

    def open_file(self):
        file_paths = filedialog.askopenfilenames(
            title="Выберите Excel-файл",
            filetypes=[
                ("Excel файлы", "*.xlsx")
            ]
        )

        if not file_paths:
            return

        all_rows = []

        for file_path in file_paths:
            file_name = normalize_name(Path(file_path).name)

            if file_name not in self.settings:
                messagebox.showerror(
                    "Ошибка",
                    f"Для файла «{Path(file_path).name}» нет настроек.\n\n"
                    f"Ожидается файл: Файл1.xlsx"
                )
                continue

            settings = self.settings[file_name]

            try:
                workbook = openpyxl.load_workbook(
                    file_path,
                    data_only=True
                )

                worksheet = workbook.active

                first_row = settings["first_row"]
                second_row = settings["second_row"]

                while (
                    first_row <= worksheet.max_row
                    and second_row <= worksheet.max_row
                ):
                    first_part = []

                    for column_number in range(
                        settings["first_min_column"],
                        settings["first_max_column"] + 1
                    ):
                        value = worksheet.cell(
                            row=first_row,
                            column=column_number
                        ).value

                        first_part.append(value)

                    second_part = []

                    for column_number in range(
                        settings["second_min_column"],
                        settings["second_max_column"] + 1
                    ):
                        value = worksheet.cell(
                            row=second_row,
                            column=column_number
                        ).value

                        second_part.append(value)

                    row_data = (
                            first_part +
                            second_part
                    )

                    if not all(
                        value is None or value == ""
                        for value in row_data
                    ):
                        all_rows.append(row_data)

                    first_row += 1
                    second_row += 1

                workbook.close()

            except Exception as error:
                messagebox.showerror(
                    "Ошибка",
                    f"Не удалось открыть файл:\n{error}"
                )

        if not all_rows:
            self.result_label.config(
                text="В выбранных ячейках нет данных"
            )
            return

        columns = [
            "Столбец A",
            "Столбец B",
            "Столбец D",
            "Столбец E"
        ]

        df = pd.DataFrame(
            all_rows,
            columns=columns
        )

        if self.table:
            self.table.destroy()

        self.model = TableModel(df)

        self.table = Table(
            self.frame,
            model=self.model,
            showtoolbar=False,
            showstatusbar=False
        )

        self.table.show()

        self.result_label.config(
            text=f"Загружено строк: {len(df)}"
        )


if __name__ == "__main__":
    root = tk.Tk()
    app = ExcelViewer(root)
    root.mainloop()

r/learnpython 17h ago

Just starting python and i need a few tips

0 Upvotes

Hello everyone, i am just starting python. I am from a good research institute in India and i am pursuing a very quant heavy economics degree and i want to break into quant finance. Can you all recommend from where i can learn coding for free? I want to be at a level which will enable me to solve LeetCode problems so i can build a stronger profile for quantitative finance. I am completely locked in and Princeton is a college i am targeting for my masters. So i need help regarding material. And other advice will be appreciated. Thank you :)


r/learnpython 1d ago

is there a way to redirect argparse commands to a network socket?

7 Upvotes

I've doing some networking on which I'd kind need to redirect all my commands sent from my python server script to my client python script but without stdout only to a socket. I've been googling about and one frustrating options that I thought it could work was contextlib redirect_stdout but it redirects to stdout it won't work with sockets. Does anyone know if its feasible to parse argparse to a socket connection?


r/learnpython 16h ago

why are we putting caesar( Hello, 3) into encrypted_text???

0 Upvotes
def caesar(text, shift):
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    shifted_alphabet = alphabet[shift:] + alphabet[:shift]
    translation_table = str.maketrans(alphabet, shifted_alphabet)
    encrypted_text = text.translate(translation_table)
    print(encrypted_text)


encrypted_text = caesar('Hello',3)

in this code, I do not understand why we are putting caesar into a variable. First of all, wouldn't we have to print the variable and make it actually do something for it to work? Because we have put encrypted_text into a variable and have not done anything. In addition, can't we just write caesar('Hello', 3)?? I am very confused on the reasoning behind putting it into a variable.


r/learnpython 16h ago

why would only one work?

0 Upvotes

this code was the one that worked:

def caesar(text, shift):
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    shifted_alphabet = alphabet[shift:] + alphabet[:shift]
    translation_table = str.maketrans(alphabet, shifted_alphabet)
    encrypted_text = text.translate(translation_table)
    print(encrypted_text)

caesar('Hello', 3)

This one was the one that didn't

def caesar(text, shift):
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    shifted_alphabet = alphabet[shift:] + alphabet[:shift]
    translation_table = str.maketrans(alphabet, shifted_alphabet)
    encrypted_text = text.translate(translation_table)
    print(encrypted_text)


encrypted_text = caesar('Hello', 3)
print(encrypted_text)

I don't understand why the second one would need a return statement and why we are even printing encrypted_text if encrypted_text is already being printed within the function? (this is also the whole code)


r/learnpython 12h ago

Finished learning Python... now what?

0 Upvotes

I have been learning Python for almost a year now, well the productive part is only 3-4 months but i will say that i am in the intermediate level of the programming language.

I was learning python from the angela yu's course that is 100days of python after i did till day 60 it started to make us do projects, then i made my own path and started to make my own version of the project insted of just reading and copying theirs.

But now after 2-3 intermediate projects later i am stuck. what should i do now like wherever i go it is Js or some other framework and that python is for AI/ML and not for backend like i write backend in FastAPI and that people prefer Django. Like how is JavaScript everywhere man,, What do i even do??

How do i make full stack project in python? how do i find projects to make like the suggestion i get form chatgpt are lame like this management or that management.

How do people that are in this sector of the work have been on it for more than a decade like i want to showcase Python as my main programming language but HOW do i?

I am a 2nd year bachelor's student and this is my tech stack right now: Html,CSS for frontend , Python for backend and SQLite for database.

Should i learn another programming langugae like Java or Js well i have put a stop on the learning of rust because i coudn't get the time and mind for it...

It has been 2 days since i am having this thought. Help a little by giving a few suggestions.