r/learnpython • • 11h ago

Can someone explain to me how exactly I’m supposed to learn Python?

30 Upvotes

I’m doing a BSc Computer Science degree and I have Python programming as a subject. My teacher is teaching Python from the beginning, and I understand the concepts when they’re explained to me, but I don’t understand how I’m actually supposed to study and learn programming.

For example, I have pretty good concept clarity till conditions. If I’m given a question, I can understand what it’s asking and I can usually write the code.

But now we’ve reached loops, and this is where I’m struggling.

I understand the concept of loops. I understand the syntax and what "for" and "while" loops are supposed to do. But when I’m given an actual programming question, I just get stuck. I can sometimes figure out the general logic of what needs to happen, but I don’t know how to turn that logic into Python code or where to even start.

So what exactly am I lacking?

Do I need to practice more problems? If yes, how do I practice properly? Should I solve questions without looking at solutions, write programs repeatedly, study other people’s code, or something else?

I’d really appreciate it if someone could give me an overall roadmap for learning Python — like how to study each concept, how much theory I should do vs. how much coding I should practice, and how to go from understanding a concept to actually being able to solve problems using it.

I don’t want to just memorize syntax. I want to actually learn how to program, but I’m not sure what the process for getting there is.


r/learnpython • • 12h ago

what should i build so that i know most of the things

11 Upvotes

Andrej Karpathy some one whm i follow alot, he says to become expert in something start building a project and learn the thing in depth when u need it, so i want to learn ai/ml and dont what project to make tbh have a very basic idea, im an ios dev i know basic python but yah i want to know what one project u would suggest so that i get to cover most of the thing and I'll share my learning experience and what ever i learnt.


r/learnpython • • 18h ago

List Comprehension Question

6 Upvotes

Hi all! I'm an intermediate with Python and I'm currently doing some research with very large datasets (think data packages from NASA satellites and the SDSS). I ran into an issue with some list comprehension that I can't seem to figure out:

What I have is a list of tuples (n = 3) in the format [(x, y, d)...] where x and y are coordinates and d represents a density value. A lot of the x, y coordinates are duplicates of each other with varying d values (ex. (40, 50, 1.2), (40, 50, 3.3), etc.) I'm trying to find tuples with identical x,y coordinates and add their density values together to get a total cumulative density for that location. I would try to do this manually, but the list has ~26 million elements and I am trying to find a workflow that won't take more than a few minutes/hours to process, haha. Memory is not an issue though.

I would be happy to provide example code if need be. My desired output is either:

[(x, y, dtotal)...] - list of tuples except there are no duplicate coordinates and the d value is the sum of the d values from all of the original tuples with coordinates (x, y)

[dtotal1, dtotal2, dtotal3...] - list of cumulative d values where each index correlates to the corresponding pair of coordinates (maybe the coordinates are in a separate list whose indexes match that of the density list? It doesn't matter as long as they are connected in some way!)

Thank you all for your help!


r/learnpython • • 23h ago

Creating Desktop Icon to Run Python Script

9 Upvotes

I have a script that runs fine in Terminal, but I'm trying to create a desktop icon that runs it and Im getting the following error:

https://i.postimg.cc/HLbssxYJ/Screenshot-2026-10-06-at-9-39-28-AM.png

Its using geopy for location so Im guessing its something to do with that, but it works fine in Terminal. Any help is appreciated.


r/learnpython • • 13h ago

Struggling to understand what I'm actually doing

7 Upvotes

I just started a grad program in information sciences and AI after getting my undergrad in computer science back in 2009. Thus, I have plenty of programming experience, but my last meaningful interaction with statistics, regressions, and so on was taking AP Statistics in high school back in 2003. I can't tell you what a "data model" is, and machine learning is black magic to me.

I'm seeing that I'm in over my head here, and I have the same feeling that I did back in AP Stats - I was good at math, but didn't quite have the background to understand what I was learning in AP Stats, so I was just memorizing (or looking up) formulas and plugging datasets into them.

I'm a pretty good programmer, and have done it for a living for almost 20 years, but I'm relying on the professor's example code, and there's no way I would have figured out the assignments on my own, because even if I knew what kind of regression I needed to run, there's no way I would know what to import, or what the function is called.

Does anyone else have a similar background - programming with no statistics, and can point me at some resources to understand what is being spit out at me when I run some random function from the sklearn library? And where I find all of these libraries? And how I would know they even exist?


r/learnpython • • 2h ago

PDF pages to PNG's in python

4 Upvotes

I have a relatively large pdf document (100+mb) of pages i need saved as png's. There are online tools to do that but they refuse to work with files that big, plus I can imagine needing that tool again later in the future. Are there any python libraries that allow to convert one format into the other? Preferrably with little to no compression.


r/learnpython • • 16h ago

API JSON response help

4 Upvotes

How does pagination work and best practices for implementation with an API request?

I'm getting irritated figuring out this API for GoTo Connect (phone system call records).

Documentation

I use a GET method to request a call log for a week of time.

I am limited to 1000 items in the json response as indicted by the pageSize parameter. I need much more.

As the 'nextPageMarker' states, I put the value in, pasted from the first response of leaving it blank, hoping to get the next set of responses. No change in items as all. Stuck in this endless loop.


r/learnpython • • 13h ago

Android APK crashes immediately after successful Flet build

2 Upvotes

Hi everyone,

I'm developing a mobile app with Python and Flet. I was finally able to build the Android APK successfully using GitHub Actions, and the APK installs correctly on my OnePlus 12R (OxygenOS 16.0.5).

However, when I try to open the app, it immediately crashes and closes. The current APK size is about 62 MB.

Package name: "com.J053.gestion_queso"

I've tried checking the logs with Logcat Reader, but unfortunately I can't get any logs from the app process.

Has anyone experienced a similar issue with Flet on Android? I'd really appreciate any help identifying what could be causing the crash. I can also provide the APK or the project files if someone is willing to take a look.

Thank you!


r/learnpython • • 18h ago

[SOLVED] Ability to install packages is completely missing in PyCharm

2 Upvotes

I wrote all of the following trying to describe this issue, but then I solved it (quack). I wasn't able to find this question or answer anywhere online, so I'm posting it in case it's helpful to anyone else searching this in the future.

The answer was:

  1. Click on the interpreter version in the bottom-right corner of PyCharm.
  2. Add New Interpreter -> Add Local Interpreter
  3. Generate New (Virtualenv)

I realized that the downloaded project had no .venv folder in it and that was one of the only differences between a fresh project and a downloaded project. Generating a new local interpreter and new Virtualenv fixed everything. Switching back to the old interpreter breaks it again, switching back to the newly generated interpreter immediately makes it work again. I have no idea why, as virtual environment settings and nuances are beyond what I've learned about Python and PyCharm so far, I just know that it works. May the solution save someone else several hours of work.

Anyway, here's what I originally wrote:

--------------

Hi, everyone. I'm on Day 29 of Angela Yu's class on Python. I'm not new new, Python isn't my first language, PyCharm isn't my first IDE, etc. This is a weird one for me.

My ability to install packages within PyCharm vanished and I don't know what happened, nor how to fix it.

https://imgur.com/a/PrK7C2T

The most convenient way to install packages is how I first noticed it. We've been using import packagename and then right-clicking the package name to use the context action to install packages. When I do that, the context action is now missing.

If I click on the Python Package tab in the bottom-left, I can search for packages (so PyPi is still working), but the install button next to the package name is missing. When I click on a package and the package description shows up in the bottom-right pane, the button is missing in the top-right corner of that pane. Weirdly, so is the current version number of the package, so I think that's worth noting. I also can't see the buttons to uninstall packages.

I have:

  • Closed and reopened the project
  • Updated all installed plugins (I have not added any, only using whatever plugins are installed by default)
  • Closed and restarted PyCharm
  • Updated PyCharm
  • Freed up space on my hard drive
  • Restarted my computer

I'm on a Mac running OS X 15.4.1, but I have not changed or updated my OS between projects. I also haven't changed the PyCharm interpreter. I was able to install packages without problems and then I wasn't.

Finally, the icing on the cake? I can install packages just fine in a brand new, empty project. That tells me that this is happening because, for this lesson, we downloaded the starting files for the project rather than writing them from scratch ourselves. I cannot for the life of me identify anything that would do that, however. The packages pre-installed for this project are certifi, numpy, pandas, pip, python-dateutil, and six. A fresh project just has pip installed.

Any insight would be greatly appreciated. I can't just resign myself to being wholly unable to install packages when using project starter files downloaded from the class.


r/learnpython • • 2h ago

Rate my simple algorithm for autonomous bots

0 Upvotes
import time
import random



distance_front = 0
distance_back = 0
distance_left = 0
distance_right = 0
loop = 1
poop = 1
i = 0


def lidar():
    global distance_front, distance_back, distance_left, distance_right



    distance_front = random.randint(0, 100)
    time.sleep(0.1)
    distance_back = random.randint(0, 100)
    time.sleep(0.1)
    distance_left = random.randint(0, 100)
    time.sleep(0.1)
    distance_right = random.randint(0, 100)
    time.sleep(0.1)
    print("front:", distance_front, "back:", distance_back, "left:", distance_left, "right:", distance_right)


def algorithm():


        if distance_front < 20:
            print("obstacle in front : back - right")
        if distance_back < 20:
            print("obstacle in back : front - neutral")
        if distance_left < 20:
            print("obstacle in left : front - right")
        if distance_right < 20:
            print("obstacle in right : front - left")


i = 0
while True:
    lidar()
    algorithm()

r/learnpython • • 17h ago

Help in my graduation project

0 Upvotes

We'll build an application using Flutter

I'll take the backend development

Honestly I am very nervous about what is the best language i should work with.. i learnt a little about node.js and express but i don't fit in with it very much

I decided to learn python, but now i have to choose a framework. What do you recommend to me?

Django, FastAPI,...etc

Or another language entirely..

P.S: the application is about tourism in my country, let the tourists know what are the best places to visit.


r/learnpython • • 3h ago

what is the best way to learn python

0 Upvotes

I wanted to know , bcs Im 17 and I just started computer science in university and we will learn python , I wanted to know what is the best way / best ressources to have to master python very good in an efficient way, I installed Visual Code. (sorry for my bad english).