Programming and IT

How to learn to code from scratch

You can teach yourself programming without a technical degree if you write code with your own hands from the first week instead of only watching lessons. Below is how to choose a first language, what to install, which order to take topics in and how to tell that you are really making progress.

Updated
In this article

Which language to choose first#

Your first language affects your path less than it seems: variables, loops and functions work much the same everywhere, and a second language takes a fraction of the time the first one did. Choose by what you want to be doing in a year:

  • websites and interfaces in the browser — JavaScript together with HTML and CSS;
  • automation, data analysis, machine learning — Python;
  • large server systems, banking and enterprise projects — Java;
  • no goal yet — Python: its syntax is simple and there is little boilerplate.

Do not switch languages in the first three months. Difficulties at this stage almost always come from programming itself, not from the language you picked. Each of these directions has its own plan: Python, JavaScript, Java.

Your workspace in one evening#

You need three things: the language's interpreter or compiler, a code editor and a terminal. For Python that means the installer from python.org and an editor such as VS Code. Check that everything works with the shortest possible program:

name = input("What is your name? ")
print("Hello,", name)

Install Git right away and create a repository for your practice code. Each solved task is a commit with a clear message. In a month you will have a history that shows how you progressed, and later it becomes the base for a portfolio.

The order of topics for the first three months#

Take topics strictly one at a time and do not move on until you have solved several tasks on your own:

  1. Variables, types, input and output, arithmetic.
  2. Conditions: if, comparisons, logical operators.
  3. Loops: going over numbers and strings, accumulating a sum.
  4. Functions: parameters, return values, scope.
  5. Lists and dictionaries: searching, filtering, counting.
  6. Working with files and handling errors.

After each topic, solve five to ten tasks on a site with automatic checking. A task counts only if you wrote it without hints; if you peeked at the solution, come back to it three days later and solve it again.

First projects: small and finished#

A project teaches what tasks do not: splitting work into parts, reading error messages, finding answers in the documentation. Start with programs of 100–300 lines:

  • guess the number, with an attempt counter and a high-score table in a file;
  • an expense tracker: enter spending, total it by category, save to CSV;
  • renaming a hundred files in a folder by a pattern;
  • a console to-do list where you add, delete and mark items as done.

Every project should have a README: what the program does, how to run it, an example of it working. Interviewers notice this habit immediately.

How to check yourself without a mentor#

Automatic checks on practice sites answer the question "does the code work". The rest you check yourself:

  • Write tests for your functions — at least three checks: a normal case, empty input and a boundary value.
  • Reread your code a week later: if you cannot understand it at a glance, rename the variables and split long functions.
  • Post a project for open code review — developer communities are happy to look at beginners' code.
  • Explain your solution out loud as if to a colleague. The place where you stumble is what you have not understood yet.

Common beginner mistakes#

Watching video lessons for hours without writing code. Copying solutions just to "close" a task. Starting a game or a social network in the first month. Abandoning a project halfway. Being afraid of error messages instead of reading them: the error text usually names the file, the line and the cause.

Step-by-step plan

  1. Week 1 — language and setupChoose a language by your goal, install the interpreter, an editor and Git, run your first program.
  2. Weeks 2–6 — the basicsVariables, conditions, loops, functions; 5–10 auto-checked tasks per topic.
  3. Weeks 7–10 — data structures and filesLists, dictionaries, reading and writing files, handling errors.
  4. Weeks 11–14 — two finished projectsPrograms of 100–300 lines with a README and tests in your own repository.
  5. Next — a directionChoose a specialisation — web, data, backend — and make a plan for the next three months.

Start learning this in your own space

The plan goes into your repository: tick off stages, keep notes — the change history shows how far you have come.

Start the plan

Check yourself

1.What does this Python code print: print(7 // 2)

2.What is x after this Python code runs: x = 5, then x = x * 2 + 1?

3.What does this Python code print: print(len("hello"))

Sources

  • The Python TutorialThe language basics from the authors of Python, free
    free
  • Pro GitA free book on Git, from the first steps to branches
    free
  • freeCodeCampFree programming courses with exercises checked automatically
    free
  • CS50xHarvard's free introduction to computer science
    free

Was this helpful?

More articles

Programming and IT How to learn Python from scratch Python is a good first programming language: code reads almost like text, and the standard library covers most everyday tasks. This plan takes you from installing the interpreter to your own scripts covered by tests in about four months, at roughly an hour a day. Programming and IT How to learn SQL from scratch SQL is the query language of relational databases. Developers, analysts, testers and managers who want to pull numbers themselves all need it. Basic queries take a few weeks to learn; working confidently with complex reports takes two or three months of practice. Below is the order of topics and ways to train on a real database. Programming and IT How to learn Linux from scratch Linux runs most servers, containers and countless devices, so developers, testers, analysts and system administrators all need the command line. The easiest way to learn it is not by reading lists of commands but by working in the terminal every day and solving small practical tasks. Below is a sequence of topics for two to three months. Programming and IT How to learn JavaScript from scratch JavaScript runs in every browser and, through Node.js, on the server too. It is easy to start — you can run code right in the browser console — but it has plenty of surprising corners, from type coercion to asynchronous code. The plan below takes three to four months and assumes you already know basic HTML and CSS or are learning them alongside. Programming and IT How to learn Java from scratch Java is a strictly typed language behind banking systems, the servers of large services and Android apps. The strictness slows you down at first, but the compiler catches many mistakes before the program ever runs. This plan takes about six months at an hour a day and leads from your first program to a small backend application. Programming and IT How to learn machine learning from scratch Machine learning means building models that find patterns in data and make predictions from them. Starting with neural networks is tempting, but it is safer to go from the bottom up — from Python and math to classic algorithms, honest evaluation and only then deep learning. Without a technical background, expect six months to a year of regular study.

More solutions