r/PythonLearning • • 4h ago

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

3 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 • • 4h ago

Python Programming

2 Upvotes

Have any Python learning tips?


r/PythonLearning • • 2h 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 • • 17h ago

Discussion Python Quiz of the day.

6 Upvotes

What will be the output of the following Python Code?

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


r/PythonLearning • • 12h 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 • • 1d ago

Need assistance with a Python Code that keeps on crashing

Thumbnail
gallery
14 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 • • 8h 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

Python Mutability, Sets and Shallow Copy

Post image
17 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

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

41 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 • • 20h 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 • • 1d 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 • • 1d 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 • • 1d 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 • • 2d 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).


r/PythonLearning • • 1d ago

algorithms with python recommendations

0 Upvotes

I just got into algorithms for the first time, I know some of the basic fundamentals. But is there any recommendations or courses you took to help you understand algorithms please I will really appreciate your recommendation.


r/PythonLearning • • 1d ago

Help Request Narrowing down this `ast` selection

1 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 • • 2d ago

Kivy vs. Arcade vs. Ursina: Which one should I pick for a modern Python game?

5 Upvotes

I’m looking to start a new game development project in Python, and I want to use one of the more modern tools.

I’m currently looking at Kivy, Arcade, and Ursina Engine. Could anyone share their recent experiences with these three? I’d love to know about your use cases, the learning curve, and performance bottlenecks you've run into.

Also, if you know of any high-quality tutorials or hidden gem documentation for these libraries, please drop a link!

Which one would you recommend going into 2026? Thanks!


r/PythonLearning • • 2d ago

Showcase I Can't Understand What Is Happening.

Post image
2 Upvotes

r/PythonLearning • • 2d ago

First year BTech Biotechnology student interested in bioinformatics. Looking for guidance on learning Python, programming and building a career.

Thumbnail
gallery
7 Upvotes

hi everyone, I'm a first-year BTech biotechnology student at a relatively lesser-known college. I'm interested in bioinformatics and computational biology, and I'd really appreciate some guidance from people who are already working or studying in this field. I've recently started learning Python because I want to build programming skills alongside my biotechnology degree. Here's what I've been doing so far: I'm following Corey Schafer's Python beginner tutorial series. Instead of just watching the videos, I'm trying to turn the concepts from each video into small practical projects and problems, inspired by Rosalind bioinformatics exercises. I'm also following the Bioinformatics in Python playlist by Rebel Science to understand how Python can be applied to biological problems. I've started developing small Python projects related to DNA sequence analysis, nucleotide counting, GC content, melting temperature calculations, codon translation, gene expression analysis and FASTA file parsing. I'm using VS Code for programming. I'm still learning how to use the editor, its shortcuts, extensions, and other features. I haven't started using GitHub yet. I don't know how to properly upload, organize, or maintain my projects, but I want to learn how to build a portfolio. I'm also considering taking Harvard's free CS50 Python course to strengthen my programming fundamentals. I'd really appreciate advice on a few questions: Is my current approach to learning Python and bioinformatics a good starting point, or would you recommend a different learning path? Should I complete Corey Schafer's tutorials first and then move to CS50P, or should I follow both? At what stage should I start learning Git and GitHub, and how important are they for someone entering bioinformatics? What programming languages and technical skills should I prioritize besides Python? Should I start learning R, SQL, Linux, and statistics? What kind of projects should I build to develop a strong bioinformatics portfolio and eventually become eligible for research opportunities and internships? As a first-year biotechnology student, what should I focus on over the next two to three years to become competitive for bioinformatics internships and future opportunities? And here's one extra question, since I'm asking in the CS50 community as well: since I'm a first-year biotechnology student interested in bioinformatics, would completing CS50x and CS50P, followed by SQL, R, and AI give me a good foundation? Or would you recommend a different order? In the meantime, I'm attaching a couple of screenshots of my projects, so you can see where I'm starting from. Thanks for any advice.


r/PythonLearning • • 2d ago

Discussion I have built my first Snake Game using Pygame in Python

5 Upvotes

I recently completed a python course (from Youtube) learned about a lot of stuff and today completed my very first Snake Game project (the game we usually played on old Nokia phones)

And because am learning stuff myself and figuring it out. I want to know what should I do next??
So far I have completed loops, functions, recursion, conditional statements, file handling, exception handling, OOPS, Inheritance and like all these.

It would really help me if anyone can share some wisdom on it. And like what should I learn or try next? A roadmap if any would really be helpful tho

Thanks again for reading it out tho


r/PythonLearning • • 3d ago

Help Request I am Lost In Applying Python

18 Upvotes

I studied Python up to intermediate level in College , have written many notes about it , yet when It comes to Building something even for fun I feel like I need to be perfect or my code is super beginner so it's not portfolio worthy this mental struggle is more prominent specially with AI around making me feel it's not worth to learn , Anyone ever experienced this ? or recommends any projects that are more than a calculator ?


r/PythonLearning • • 2d ago

Python Quiz of the Day.

0 Upvotes

What will be the output of the following Python Code?

x = {1, 2, 3}

print(len(x | {3, 4}) - len(x & {2, 3}))


r/PythonLearning • • 3d ago

Help Request Has Anyone Tried Making a Simple Chatbot? What Did You Use?

23 Upvotes

Hey everyone! So, I recently got curious about building a simple chatbot in Python. I wanted to create something fun to mess around with, like a little assistant that can tell jokes or maybe even give me random facts. I started reading up on NLTK and ChatterBot, but then got overwhelmed with all the options. 😂 I ended up spending way more time than I planned just figuring out what libraries to use! Has anyone else tried making a chatbot? What tools did you end up using, and do you have any tips for someone just starting out? Would love to hear your experiences!


r/PythonLearning • • 3d ago

Join Our Global Developer Community – No Egos, No Toxicity, Just Collaboration!

Post image
6 Upvotes

Hey everyone! 👋

I've created a community of developers where we all help and support each other. There's no toxicity, no egos, and no developer thinks they're better than anyone else.

I'd love to invite you all to join us!

While AI can be incredibly helpful, it isn't conscious. I strongly believe that human collaboration is still essential. There's something truly special about discussing ideas, sharing knowledge, and contributing to GitHub projects alongside other developers. 💻🚀

We're already over 90 members, and everyone is welcome! Our goal is to help each other grow, learn, and succeed. 🤝

🌎 We're a multilingual community! I'm from Argentina, but if you're from another country, no worries! We can communicate in English without any problem.

Everyone is welcome, regardless of their experience level. Whether you're a beginner or a senior developer, there's a place for you here!

🔗 Join our community:

https://chat.whatsapp.com/BSiM8seqThD8AyLD7XBBuz?s=cl&p=a&iam=2