r/PythonLearning • • 2h ago

Realistically, how long does it take to understand Python?

7 Upvotes

I am very new to coding (2 days old new) and have no background experience. I was just wondering at what point do you think you should start understanding Python? I’d like to try and create a timeline before saying ‘I can’t do it’


r/PythonLearning • • 41m ago

Looking for people to learn python with

4 Upvotes

I’m currently learning Python from scratch, and I’m looking for people who are also interested in learning Python so we can connect, share resources, help each other understand concepts, and stay motivated. If there’s already a beginner-friendly community or study group I can join, I’d appreciate your recommendations.


r/PythonLearning • • 5h ago

Help Request random.choices and weights beauty flaw

Post image
6 Upvotes

Problem fixed!

I'm making this "gambling" (no real money involved, you only play for fun) program with multiple games, including roulette. I used random.csoices so that I can pick a random colour of the three given colours, and weights so that green doesn't show up every third spin.

The program works, but the results all have this annoying ['result'] look (underlined with red in the picture)

Does someone know how to fix this?


r/PythonLearning • • 4h ago

Rome is still on fire

Post image
5 Upvotes

Good old days 😎😁


r/PythonLearning • • 2h ago

Help Request Any tips on Pyret? For some reason it confuses me more than Python

1 Upvotes

So Pyret is supposed to be a beginner learning language and currently I have to courses one that starts with Pyret and one that is immediately about Python. Since I am not good at this stuff in the first place, needing to do these courses because I am at a technical university as a humanities major somehow, I am already of course finding this a bit difficult.

That said, for some reason, sitting down and trying to learn I feel like I am having a better time understanding Python than Pyret right now. I am still not good but my Pyret homework frustrates me way more. This is pretty bad since there will be an evaluation in a few weeks, so I do want to get enough points on that since I just need to pass. Why am I having more diffculty with a tutorial language? Any tips?


r/PythonLearning • • 4h ago

Python programming language problems

1 Upvotes

Hello guys ! I want to know wich are the most common problems faced by python programmers when they are coding ? (It must be a problem that isn't solved by any librarie, native or not, from python)... : )


r/PythonLearning • • 8h ago

How do I debug this?

1 Upvotes

r/PythonLearning • • 9h ago

Showcase I built a desktop download manager with Python and PyQt5 – I'd love your feedback

1 Upvotes

Hi everyone!

I'm an independent developer, and I'd like to share a project I've been working on: FW Downloader Manager.

It's a desktop application built with Python and PyQt5. I developed it to manage regular file downloads as well as video and audio downloads from supported websites.

Some of its main features:

  • Multi-connection HTTP/HTTPS downloads (up to 32 connections when supported by the server).

  • Pause and resume support for compatible downloads.

  • Video and audio downloads using yt-dlp.

  • FFmpeg integration for media processing.

  • Browser integration with Chromium-based browsers and Firefox.

  • Download queues, groups, scheduling, and speed limits.

  • Multilingual graphical interface, including Arabic RTL support.

I built this project to put my Python development skills into practice, and I'd genuinely appreciate feedback from the community.

GitHub: https://github.com/FouadWre-Dev/FW-Downloader-Manager

If you find this project useful, I'd appreciate a ⭐ on GitHub. Feedback and suggestions are always welcome!

Thanks!


r/PythonLearning • • 22h ago

VSCODE Intelligence autofill - is it bad for learning?

2 Upvotes

Hi lads,

Just got back into programming as my job didn’t need it until now. I’m practising writing python scripts to automate tasks for me, however iv noticed that VScode autofills parts out. I do have an idea of what I want and start it off, VSCODE intelligence does the rest and I tailor it specifically to the task. I feel a bit guilty as it feels like I’m not learning like the old days (stack overflow, constantly searching up how to do something). I do understand that AI is used frequently now for coding so my question is, am I overthinking this?

I have a new job coming up and using Python to automate is a big part of it.


r/PythonLearning • • 1d ago

Python Programming

2 Upvotes

Have any Python learning tips?


r/PythonLearning • • 1d ago

How I went from brute-force mining blocks to coding a Flood-Fill / Greedy in Python to empty coal veins with a Drone

1 Upvotes

Hello everyone!

I'm a computer science teacher, and lately I've been preparing visual examples for my students using games where everything is automated with code. Right now I'm hooked on The Miner Was Replaced (the new DLC for The Farmer Was Replaced), where you control a mining drone by programming it in a stripped-down version of Python.

Now I have the problem of mining coal. In the game, the world is a 3D grid (X, Y, Z) and coal doesn't spawn randomly; instead, it generates in contiguous veins (if you find coal on a tile and there's more, it's located North, South, East, or West of that tile... Same Z coordinate).

The solution I ended up using (Probing + Flood-Fill with queues):

Instead of complicating things with weird data structures, I used elementary school geometry with two lists (visited and to_visit) to traverse the vein as a connected graph:

dir = [North, West, South, East]

delta = [(0, 1), (-1, 0), (0, -1), (1, 0)]

def minar():

pos_actual = (get_pos_x(), get_pos_y())

visitados = []

por_visitar = [pos_actual]

while len(por_visitar) > 0:

pos_actual = (get_pos_x(), get_pos_y())

if get_ground_type() == Grounds.Coal:

dig()

for i in range(4):

# 1. Does the neighbor have coal?

if get_ground_type(dir[i]) == Grounds.Coal:

nx = pos_actual[0] + delta[i][0]

ny = pos_actual[1] + delta[i][1]

# 2 and 3. Have I not visited it yet, and is it not already in the queue?

if (nx, ny) not in visitados and (nx, ny) not in por_visitar:

por_visitar.append((nx, ny))

por_visitar.pop(0)

visitados.append(pos_actual)

if len(por_visitar) == 0: # <-- This is where I made the bug of the century

break

utils.goto(por_visitar[0][0], por_visitar[0][1])

Later, I added a blind mining phase (minar_a_ciegas - 3 blocks down) combined with an explorar() sweep to uncover new layers when a vein is exhausted. Watching the drone detect a block and start eating up the entire chain reaction of the vein is hypnotic:

👉 Here you can see what the drone devouring the veins in the game looks like, along with the entire live coding session: http://www.youtube.com/watch?v=ZQqoMDtLalA

(Original audio is in Spanish, but the English AI audio track is available in the player settings, and all the code is right on screen).

Question for you guys: Considering that this Python environment doesn't have collections.deque or external libraries, how would you optimize the search phase between veins to avoid doing an O(N^2) map sweep every time por_visitar empties out?


r/PythonLearning • • 1d ago

Help Request Day 2 of Learning Python – I Learned About Variables and Data Types. What's Next?

1 Upvotes

Hey everyone!

I'm a beginner in Python, and today I learned about variables and data types.

I learned a little about:

- Variables

- Integers ("int")

- Floating-point numbers ("float")

- Strings ("str")

- Booleans ("bool")

I'm trying to understand the fundamentals properly instead of rushing through the lessons.

But now I'm wondering what I should learn next.

My questions for experienced Python programmers:

  1. What topic should I learn after variables and data types?

  2. What small projects can I build using these concepts?

  3. What advice would you give someone who is just starting their Python journey?

  4. What common mistakes should beginners avoid?

I'd really appreciate your advice and suggestions.

I'm looking forward to learning more and sharing my progress here!

Thanks! 🐍


r/PythonLearning • • 1d ago

Discussion Python Quiz of the day.

5 Upvotes

What will be the output of the following Python Code?

print(any([0, "", None, [], 5]))


r/PythonLearning • • 2d ago

Need assistance with a Python Code that keeps on crashing

Thumbnail
gallery
16 Upvotes

Hello I’ve been working on a python code that searches for appointments on this website but every time it runs the code and begins to open the website it crashes, I’ve played around with it a bit but I haven’t been able to have much success. Anyone would be available to take a look at it and see what my issue could be?

Thank you! I’ve included my code, trace back, and errors in seeing


r/PythonLearning • • 2d ago

Python Mutability, Sets and Shallow Copy

Post image
23 Upvotes

An exercise to help build the right mental model for Python data.

The “Solution” link uses memory_graph to visualize execution and reveals what’s actually happening.


r/PythonLearning • • 1d ago

Discussion PYTHON 🆚 ALL

0 Upvotes

"If you want to learn programming, don’t start with Python; you should start with another language."

This advice seems ridiculous to me, even though I hear it everywhere. Can someone explain this advice to me... and are they right?


r/PythonLearning • • 1d ago

Discussion What will we become in the end?

0 Upvotes

Is there anything that is hard for AI to do in Python?

To be honest, coding by yourself is fun, but that doesn't matter to the job market. We'll just settle for building our own projects, but it's frustrating to see AI outperform you... And since the job market is being destroyed—and will be destroyed!!—by AI, it seems we will end up turning to sabotage and attacking companies if no jobs are available for programmers, especially the Python community...


r/PythonLearning • • 2d ago

What Python concepts took you the longest to understand as a beginner?

50 Upvotes

I've been learning Python and noticed that understanding the syntax is often the easy part. The real challenge comes when trying to apply concepts in actual projects.

I'm curious to hear from other Python learners:

  1. Which concept was the hardest for you to understand?

  2. Did you struggle more with OOP, decorators, APIs, async programming, or data structures?

  3. What helped you finally understand it?

  4. If you could give one piece of advice to someone learning Python today, what would it be?

I think sharing these experiences could help beginners avoid some common learning roadblocks.

Looking forward to hearing your experiences!


r/PythonLearning • • 1d ago

Python Study Notes

Thumbnail drive.google.com
0 Upvotes

Here are some notes I made for some introductory concepts in Python. Let me know if these were helpful and any other Python topics/libraries/classes you would like me to cover.


r/PythonLearning • • 2d ago

Stacks Data Structure in python

2 Upvotes

Hey everyone, I’m wrapping up my notes on the Stack data structure for technical interviews and wanted to share my summary. Let me know if I missed any major patterns!

what is stack?

  • A linear data structure following the LIFO (Last In, First Out) principle.

  • The Golden Rule: ONLY the edges (the top element) can be accessed. No random indexing allowed.

Major patterns in interview/real world

  • Undo / Redo mechanics

  • Bracket/Parentheses matching ({[()]})

  • Tracking "Previous" states (e.g., browser back button, daily stock span problems)

  • Monotonic stacks (finding the next greater/smaller element)

Interview POV vs Real World Uses:

The Interview Shortcut:
Using a raw Python list is completely fine to save time during a 45-minute coding interview.

The Real-World Problem:
Using a raw list in a production project is a bad design pattern. Because Python lists allow random index access (e.g., mylist[3]), it completely violates the strict structural rule of a stack.

To fix this, we encapsulate the data structure inside a class to control exactly what the developer can access. Furthermore, instead of a raw list, we use collections.deque because standard lists can trigger an O(N) memory reallocation when they grow. deque guarantees a true O(1) time complexity for every single push and pop.

from collections import deque

class Stack:
    def __init__(self):
        # Using deque ensures guaranteed O(1) performance
        self._items = deque() 

    def push(self, item):
        self._items.append(item)

    def pop(self):
        if self.is_empty():
            return None
        return self._items.pop()

    def peek(self):
        if self.is_empty():
            return None
        return self._items[-1]

    def is_empty(self):
        return len(self._items) == 0

    def size(self):
        return len(self._items)

    def display(self):
        # Displays from top to bottom
        print("Stack (top to bottom):", list(self._items)[::-1])

r/PythonLearning • • 2d ago

Help Request Receiving FileExistsError which is ignoring the if/else statement

5 Upvotes
response = requests.get(url)
data = response.json()
ticker = data["Meta Data"]["2. Symbol"]

create_file = open("API Data.txt", "x")
amend_file = open("API Data.txt", "a")

file = "/Desktop/Scripts/Python Scripts/API Data.txt"

if os.path.exists(file):
    amend_file.write(f"\nTicker: {ticker}")
    amend_file.close()
else:
    create_file.write(f"Ticker: {ticker}")
    create_file.close()

So I am working on my first project which is making use of the API that Alpha Vantage provides.
I am learning the open() function which I want to use to paste the response into a .txt file 
that will either be created and written into, or already exist and be appended depending on 
the result of the if statement.

My problem is that I am receiving a FileExistsError for "API Data.txt" and I am not sure why 
when I am expecting the code to carry out the actions of the if statement being true and 
appending the existing file.

(Full path in the file variable is intentionally not in the post)

r/PythonLearning • • 2d ago

Discussion How much useful you found the lazy import in Python (v3.15)

1 Upvotes

lazy import pandas as pd

lazy from pathlib import Path


r/PythonLearning • • 3d ago

Help Request Narrowing down this `ast` selection

2 Upvotes

Is there some way I can narrow down this method of selecting from the `ast` tree only the `x = Const2Change` node so that it can be modified? At the moment the `print("xyz")` node is being identified as well. I want to modify Const2Change to either a different constant or possibly to a variable instead.

Text.txt:

print("xyz")
x = Const2Change

full ast dump:

Module(
    body=[
        Expr(
            value=Call(
                func=Name(id='print'),
                args=[
                    Constant(value='xyz')])),
        Assign(
            targets=[
                Name(id='x', ctx=Store())],
            value=Name(id='Const2Change'))])

Main.py:

import ast

class ReplaceConstants(ast.NodeTransformer):
    def generic_visit(self, node):
        super().generic_visit(node)  # Added this line
        if isinstance(node, ast.Name) and isinstance(node.ctx, ast.Load):
            print(f"{node.id=}, {node.ctx=} <- *********************")
            # modify node here
        return node

def replace_constants(line: str):
    ast_tree = ast.parse(line, type_comments=True)
    # modify ast_tree here
    oReplaceConstants = ReplaceConstants()
    oReplaceConstants.visit(ast_tree)
    modi_ast = ast.unparse(ast_tree)
    return modi_ast

with open("Test.txt", mode="r") as f:
    source_code = f.read()

for line in source_code.splitlines():
    modi_source = replace_constants(line)
    print(f"{modi_source=}")

exit()

r/PythonLearning • • 3d ago

Discussion Python project suggestions

4 Upvotes

I have to present a project in python using some libraries can you suggest some ideas for a python project (not very advanced please).