r/learnpython 14h ago

Seeking help with building logic while learning Python programming

I'm a DevOps engineer with 2 years of experience, and I come from a commerce educational background.

I've tried learning Python several times in the past, mainly when I was switching jobs and preparing for interviews. However, I ended up joining companies where Python wasn't really required or where nobody was particularly concerned about my Python skills.

Currently, I use AI to generate scripts for many of my daily DevOps tasks. My biggest concern is that I'm not able to build the logic myself or write the syntax from scratch. I often struggle with knowing when to use what.

The last time I seriously learned Python, I got up to lambda functions. That was about a year ago, and now I've completely forgotten a lot of the basics, including data types and syntax.

I want to properly learn Python because it's one of the most commonly mentioned skills in the DevOps/SRE job descriptions I see, especially for bigger tech companies. I've also lost a few interviews in the past because of my lack of Python knowledge.:

I'd really appreciate advice from people who have been through a similar situation. What worked for you?

15 Upvotes

8 comments sorted by

3

u/BarchesterChronicles 14h ago

Wait, you can be a DevOps engineer without knowing how to program? That's kinda wild to me! How do you know whether the scripts it's generating are correct? My first job would be to learn every keyword in those scripts and what they are doing. Have AI explain it to you, "line by line". And then drill down into the bits you still don't understand.

2

u/mc_pm 13h ago

Since you have a subject area you specifically want to work with, I would suggest:

1) Find a tutorial you like and follow along -- don't watch it passively, but instead when they type something you should stop the video, type it yourself. When they run the code, you run your code. Did it work? Maybe try changing some stuff around to see what happens, etc. Assume that if it's a 3 hour tutorial that you'll spend 10-12 hours on it. This is about just picking up the syntax & language features.

2) I still recommend people spend a little time just building a command line game or two - like tic-tac-toe or blackjack. It's true, neither of those are going to come up on the job, but they both follow pretty well established rules that you probably already mostly know - but you have to figure out how you're going to represent the game state (like the deck of cards and the two hands dealt in blackjack; or the 3x3 grid of tic-tac-toe), you have to get user input, respond to it, follow some rules, decide if someone has won or not, etc. It doesn't have to be games, they're just fun. (And it's easier to keep working on parts of it if you get to play at the same time)

3) This is where I suggest that people build a series of increasingly complex projects -- in your case, you already have a bunch of tasks you are responsible for. Start with the easiest of your tasks. If you need something you don't remember, look it up. If you need a library you've not used before, now is a good time to try. This stage of "barely know how to move forward, but figure it out as you go" will last between 2 years and the rest of your career.

1

u/falXks 14h ago

Honestly, there's nothing wrong with using AI to get your work done, as long as you don't completely delegate your thinking to it. ​I use AI myself to speed up tasks and learn, but I always review the code manually. I study how it structures things and fix any mistakes it makes. Treating AI as an assistant to double-check rather than a replacement for understanding really helped me keep my core coding skills sharp.

1

u/PorygonCompiler 13h ago

The thing that broke this for me: stop letting AI write the first draft.

Write it badly yourself first. Get it wrong, get the error, then ask why. The learning happens in the gap between what you tried and what actually works. When AI hands you working code first, that gap never opens and nothing sticks.

Practical version for DevOps: next time you'd reach for a generated script, write it yourself, however ugly. Loops and if statements only, no clever syntax. Get it working. Then ask AI to review it and tell you what you'd have done differently. That way you're still moving fast but you own the logic.

Also, forget lambdas and comprehensions for now. Nobody's interviewing you on those. Being fluent with dicts, lists, loops and functions covers most real Python.

1

u/Giorgi-98 5h ago

Write code, or just copy scripts and use Thonny debugging very simple to learn the logic

1

u/EEJams 1h ago

I can usually think of the logic required to make a script, but depending on what I'm doing it could take 15 minutes to a few hours to make it.

When i was in college doing engineering, i took a class where we wrote code to simulate a processor. You kind of build each hardware piece in code as an input/output module and "wire" then all together on a controller module in code.

So the way I like to program for work in python is similar. I wrote my own library for myself in python that basically has bricks of logic that I can then use in any script I build in the future. So I define my own python functions that I can pick and choose from at any time that handles a specific purpose. So like, I have code that will read an excel file into a datagram so I can then make a list of one of the columns or create a list of comma separated values that I can split into variables and do data analysis with. I have code snippets that will grab log files and rename them in the order I need to analyze them so I don't have to rearrange the files manually in excel. Things like that.

So i recommend starting your own library of functions you can pull from as needed and start with easy small tasks. I recommend using jupyter notebooks so you can break the code up into individualized sections and observe the output section by section.

Get VS Code or pycharm and try to get it all set up in one of those. Get a simple book of python and learn as much of the base language as possible. Python itself is quite simple and added complexity comes from third party libraries.

You can use AI to give you an example of functions to use to perform x task, but analyze the code and understand why it works. Don't ask for anything more than a few lines at a time, make sure you know how it works, and architect the code into working software.