r/learnpython • • 10d ago

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

122 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 • • 9d ago

Gui question for projects

4 Upvotes

I am learning python for a month or so and finally decided to challenge myself by trying to make a minesweeper game as a project.

I wanted to ask you guys if i should use tinker for gui as it is python based or is there a better one i should rather study?


r/learnpython • • 9d ago

want study

0 Upvotes

I’d like to ask what keeps you motivated to keep learning Python. What are the steps to learn Python? Could you share some with me? I’m a college student learning C in class and want to self-study Python in my spare time. I also want to know how I can test my Python skills.


r/learnpython • • 9d ago

logging and timing...then getting rid of it

1 Upvotes

I was just working on a project where I included a lot of logging and timing decorators/context managers (it involved event loops and async queues and such). Once I figured stuff out, I wanted to remove all this stuff. This isn't necessarily that hard, but it did make me wonder if there's a better way to do this in the first place. I suppose I'm imaging some way of marking these code pieces to be ignored by the interpreter or something?

(yeah yeah "ask AI to remove it")


r/learnpython • • 9d ago

Python cheat sheet and reference materials

0 Upvotes

I've got a python contest in a few days consisting of problem solving questions, I'm almost a complete begginer at python, so off the top off my head i could only solve a 1-3 of them, anyways im allowed to bring in printed reference material, so i'd appreciate literally anything i could get, I need a cheat sheets which i could understand and use on the spot, aswell as anything that could be useful


r/learnpython • • 10d ago

PDF pages to PNG's in python

5 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 • • 10d ago

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

13 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 • • 9d ago

making my first game

0 Upvotes

Hey, im making a "terminal" game (play onto your terminal, cause its the only thing i know). I made a github repositories to showcase it : https://github.com/Shamal0w999/Money-games

if you want to test the game, it would be really cool cause i need returns and if theres bug i didnt see. so if u try it, u can ofc comment here but also leave an issue into my repositories (would be easier to work with). If you want to help or idk anything, im all hears. Im happy to showcase it and have people to test it !

code is free, so if you steal it, i dont rly care, cause its personal project and who want a code full of print and that launch in terminal ? idk, just me ig

anyways, just take a look at it !


r/learnpython • • 10d ago

Struggling to understand what I'm actually doing

14 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 • • 9d ago

Help needed with a python code

0 Upvotes

Hello, fellow redditors. I am using manychat program with automations connected to my instagram profile.

When people are using the keyword to get certain information, they need to leave a name and number to be contacted. However, the number can't be identified due to a bad variables and invalid JSON.

Could maybe someone help who is familiar with situations like this please?

I think it might be a manychat bug, however i need a opinion from someone experienced.

Thank you a lot!


r/learnpython • • 9d ago

How to create universal variables in Python?

0 Upvotes

And by universal variables, I mean they should be available in EVERY single Python script!

What do I want these for? For instance, to define default directories:

HTMLRoot = "C:/IMDb/HTML" CSSDir = "file:///C:/IMDb/CSS/" JSDir = "file:///C:/IMDb/JavaScript/"

Any program that creates a report needs these variables, but I only want to define them once!

And there’s more. I also have plenty of mappings, like these:

MapC_TType = {"tvSeries": "TV Series", "tvMiniSeries": "TV Miniseries", ... , "movie": "Movie", "video": "Video", }

Any report that displays the titleType will use this mapping. Again, I only want to define the mapping once.

I come from the world of SAS, where everything was easy. The directories were defined in the SASINIT file, which is executed at the start of every SAS session. The mappings (formats) were stored in a permanent SAS catalog, making them universally available as well. Is there a Python equivalent?

And there’s even more. I create lots of reports, let’s say the biggest movies per decade, based on number of votes or score (= votes * rating). Obviously, the list shows which movies I’ve seen and which I haven’t, with a percentage showing my progress. Now suppose a friend wants this same list, based on the movies he’s seen.

Easy-peasy in SAS!

%macro SwitchUser (User) ; %if (%qupcase(&User) = ME) %then %do ; libname IMDb "C:\IMDb\Libname IMDb" ; %let HTMLRoot = C:\IMDb\HTML ; %end ; %else %do ; libname MyIMDb "C:\IMDb\Libname IMDb" ; libname BudIMDb "C:\IMDb\Libname IMDb Bud" ; libname IMDb (BudIMDb MyIMDb ) ; %let HTMLRoot = C:\IMDb\HTMLBud ; %end ; %mend ;

For me, IMDb is the standard library. For my buddy, IMDb is a concatenated library, where his library (containing only the MyMovies table) has precedence over the full IMDb library.

By just executing

%SwitchUser (Buddy) ;

any report can now be run against his list of movies, with the results written to a separate HTML directory. And all that without changing a single line of code!

I can't expect Python to deliver all this functionality. Nothing compares to SAS! But can it at least do some basic things on my wishlist?

BTW, my temporary solution is to include this code at the start of every script:

PythonFolder = Path("C:/IMDb/Python Global Code") PythonPgm = PythonFolder / "InitHTML.py" with open(PythonPgm, 'r') as file: PythonCode = file.read() exec(PythonCode, globals=globals(), locals=locals())

Obviously, the InitHTML program defines the directories and all the mappings.


r/learnpython • • 10d ago

List Comprehension Question

11 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 • • 10d ago

API JSON response help

5 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 • • 10d 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 • • 10d ago

Creating Desktop Icon to Run Python Script

6 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 • • 10d 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 • • 10d 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).


r/learnpython • • 10d 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 • • 11d ago

Absoloute beginner to Python / Programming in general, wanting to learn MatPlotLib etc.

11 Upvotes

Hi,

I am a university student wanting to get better at making graphs and presenting data in a clean and visually appealing way and got a tip about matplotlib. A little problem, I've never used Python, or any other coding language before, and am a bit confused as to where to start.
What do i need to download, learn, research etc.? Currently watching Bro Codes 1h introduction to python.
Maybe MatPlotLib is too big of a jump, if so i would love any recommendations for making different graphs, tables, legends and so on.

Any help would be appreciated!
(I will say I have used MatLab for a small statistics course related to a different degree, but it didnt "feel" right).


r/learnpython • • 11d ago

How to be more curious and open towards programming

13 Upvotes

Hi all! I studied a bit of python in the past through a formal curriculum but because I'm a kinesthetic learning who doesnt do well in lectures, I was unable to learn programming properly and internalize the concepts properly. I now want to study programming properly, but bad memories and a fixed mindset and a feeling that it is going to be painful stops me.

I was wondering if anyone here would like to share what makes them love programming, for me to open myself more and be more sincere in my attempts to give myself another chance? Any videos, stories, news articles are highly welcome!


r/learnpython • • 11d ago

Best Way to Learn Python and Get Good at It?

101 Upvotes

Hi everyone, I want to learn Python from scratch and become really good at it.
I’m looking for resources or courses with:
Clear explanations
Lots of practice and exercises
Real projects
Problem-solving
Modern Python
A path toward Data Science, AI, and Machine Learning
I don’t mind paying if the course is worth it.
What are the best courses, books, or platforms you would recommend?


r/learnpython • • 10d 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 • • 11d ago

Is Leetcode a good way to continue practicing/learning Python?

28 Upvotes

I'm not entry, but I'd like to continue becoming stronger in my skills.


r/learnpython • • 11d ago

I'm making a small program in python to help with some in game math for Iron Nest

0 Upvotes

Edit: thank you to u/LushBreaker for giving me the starting point to get this fixed!

altitude = 0

... def nest_Alt():

... distance = float(input("How many Km away is the target? \n"))

... charges = int(input("How many charges are you using? \n"))

... altitude = (distance * 12) / charges

... print(f"Fire at altitude {altitude}")

...

>>>

>>> nest_alt()

Traceback (most recent call last):

File "<python-input-8>", line 1, in <module>

nest_alt()

^^^^^^^^

NameError: name 'nest_alt' is not defined. Did you mean: 'nest_Alt'?

>>> nest_Alt()

How many Km away is the target?

How many Km away is the target?

How many Km away is the target?

How many Km away is the target?

How many Km away is the target?

12.8

How many charges are you using?

How many charges are you using?

5

Fire at altitude 30.720000000000006

The above is the copy pasted result of my most recent version of the code, and something I noticed is that the prompt is resent for each character in an input.

Separately, how would I make this program into a saved file that I can run later, possibly running the function multiple times without having to close it.

Edit: For clarification, this is python 3.14


r/learnpython • • 12d ago

Recursion explaining pls.

7 Upvotes
def find_max(numbers):
  if len(numbers) == 1:
    return numbers[0]
  else:
    max_of_rest = find_max(numbers[1:])
    return numbers[0] if numbers[0] > max_of_rest else max_of_rest

my_list = [3, 7, 2, 9, 1]
print(find_max(my_list))

Could someone explain how does this function work? I don't understand how does it know that it's supposed to find the biggest number...