DEV Community

Cover image for My Python Class — The Golden Rules of Programming
Karthick (k)
Karthick (k)

Posted on

My Python Class — The Golden Rules of Programming

1. Never Say "I Don't Know" — Say "Let Me Try"

The first rule, and maybe the most important mindset shift. When you look at a program and feel lost, the instinct is to freeze and say "I don't know this." Instead, the habit to build is saying "let me try" — even a small attempt moves you forward, while "I don't know" keeps you stuck.

2. Known to Unknown

Start solving a problem from what you already know, and work your way toward what you don't. Don't try to jump straight to the unfamiliar part — build up to it step by step from familiar ground.

3. Don't Think About the Entire Output

Don't get overwhelmed trying to picture the whole final result all at once. Break the problem down and focus on getting the next small piece working.

4. Think About the Entire Output

At the same time, keep the big picture in mind — know what the end goal actually looks like, so your small steps are still heading in the right direction. (Sir made it sound like these two — don't fixate on it, but don't lose sight of it either — work together, not against each other.)

5. Introduce a Variable Only If It Simplifies the Solution

Don't add variables just because you can. Every variable should earn its place — if it doesn't make the logic clearer or simpler, you probably don't need it.

6. Micro to Macro

Similar to "known to unknown" — start small. Get the tiniest piece of logic working first, then build outward into the bigger, complete solution.

7. Dry Run Before You Run

Before actually executing the code, trace through it by hand (a "dry run") — walk through the logic step by step on paper or in your head. It catches a surprising number of mistakes before you even hit run.

8. Every Program Has Three Parts: Input, Process, Output

No matter how complex a program looks, it always breaks down into these three stages — something comes in, something happens to it, and something comes out. Keeping this structure in mind makes any problem easier to approach.

9. Logic First, Syntax Next

Figure out what the program needs to do and how it should do it before worrying about the exact syntax. Syntax is something you look up; logic is something you build.

Top comments (0)