r/learnprogramming • • 2h ago

[Python] I can read and understand code, but I freeze when starting from a blank screen. How do I learn to structure a program from scratch?

I've learned the basic syntax (loops, functions, conditionals) and can follow along when reading existing code. However, when I open an empty file to build something on my own, I don't know which tools, data structures, or design steps to choose first. What exercises, books, or habits helped you bridge the gap between understanding syntax and designing a program from scratch?

2 Upvotes

13 comments sorted by

3

u/BeastWael_YT 1h ago

one thing that helped a lot is separating "what" from "how" before typing any code. write down in plain words what the program takes in, what it gives back, and the 3-5 steps between, then each step becomes a small function you can code alone. also try rebuilding tiny projects from scratch with no tutorial open, like a habit tracker or a text-based quiz, and only look stuff up when you're truly stuck. the blank screen feeling fades once you've done that loop a few times.

1

u/Icy_Bodybuilder_3181 1h ago

Thanks for help

2

u/YogurtclosetLow7064 2h ago

That's completely normal. Don't get discouraged; eventually, things will just click.

Start with small exercises: add two numbers, check if a number is even or odd, find the largest of three numbers, reverse a string, build a simple calculator, or create a number guessing game.

1

u/Icy_Bodybuilder_3181 2h ago

I can do these type of problems but don't know the next step of programming on what to do?

I can make websites and apps with functional databases with claude but cannot write code myself or design anything. on blank page i get stuck without ai

I wanted to make a blueprint in my brain that certain type of problem can be solved or designed like this but cannot see the steps to reach that

3

u/YogurtclosetLow7064 1h ago

Don't use AI

2

u/Away_Ranger_6458 2h ago

Start by writing the whole program in plain English comments first: what inputs go in, what steps transform them, and what comes out. Don't worry about picking the perfect data structure up front. Get a tiny, ugly version working with basic lists and dicts, then refactor only when it feels awkward. Doing small CLI tools (like a todo list or expense tracker) builds that muscle fast.

1

u/Icy_Bodybuilder_3181 1h ago

Thanks for the help!

2

u/DoctorImpossible9316 1h ago

nowadays reliance on AI code scaffolding is high, but previously I start from the highest-level of hw I prefer to run the code,
For e.g,

func main() {
server := echo.New...
// register routes
routes.Register(server)

// setup middlewares
mwares.Setup()

// start service
server.start()
}

then I go to routes sub-package, do same there until I reach the most basic level
same for mwares, etc

At least that worked for me usually before I begin to fix bugs and architecture

•

u/OkFarmer3779 33m ago

what helped me was writing the dumb plan first, like 3 lines in plain words of what the program should do, then turning each line into a function. pick a small thing you actually want, like a discord bot or a todo cli, and build it ugly first. the structure only makes sense after you've made a mess once

•

u/masterofaiml 32m ago

You need to keep practicing, it’s the only way to learning any programming language. Try www.pythonmastery.io, you have everything here for you to learn and practice python.

Cheers!

•

u/cyrixlord 25m ago

Developers don't stare at a screen then just start writing. They already broke their problem down into steps and researched the best way to approach things and developed a plan on what needs done. Until you map out your project and what you are going to write into steps and how you'll do it, you'll just keep staring

•

u/binarycow 6m ago

Let's say you wanted to make a basic "paint" application.

Break it down into its pieces:

  • You need a GUI - a window people can open, close, move around, etc.
  • Read and save files
  • Display an image
  • Color pallette
  • Tool selection
  • Update the image based on mouse position and button status

Now, work on one piece at a time. You may need to break that piece down further.