Python is often recommended as a first programming language, and for good reason. Its syntax is clean and close to everyday English, it runs on every major operating system, and the same language is used for automation, websites, data analysis, scientific research and artificial intelligence. Guido van Rossum released the first version in 1991 and named it after the British comedy group Monty Python, not the snake. Today it is taught in schools and universities worldwide and used at companies from small start-ups to NASA. This guide shows how to go from never having written code to building your own small programs.
Step 1: install Python and a good editor
Download Python 3 from the official website, python.org. Python 2 reached its end of life in 2020, so ignore any tutorial that still uses it; you can recognise old code by statements like print "hello" without parentheses. On Windows, tick the option Add Python to PATH during installation, which lets you run Python from the command line. On macOS and Linux, Python may already be installed, but installing the current version from python.org is still recommended.
Next, install an editor. Visual Studio Code with the official Python extension and PyCharm Community Edition are both free and popular. Python also comes with a simple editor called IDLE. If you want to start without installing anything, browser-based environments such as Google Colab or Replit let you run Python online.
Finally, open a terminal, type python (or python3 on some systems) and press Enter. The three angle brackets that appear are the interactive shell. Type 2 + 2 and you will get 4. This shell is perfect for trying small ideas instantly.
Step 2: learn the basics in a sensible order
Each topic builds on the previous one, so the order matters.
- Printing and variables. print() shows output; a variable is a name for a value, such as age = 15. Python works out the type by itself.
- Basic types. Integers, floating-point numbers, strings and booleans. Learn f-strings, such as f"Hello, {name}", which insert values into text neatly.
- Input and conversion. input() reads what the user types, always as a string, so you convert it with int() or float() before doing maths.
- Conditions. if, elif and else. This is where you meet Python's most distinctive feature: indentation. The spaces at the start of a line define which code belongs to a block. Use four spaces, as the official style guide PEP 8 recommends.
- Loops. for loops with range() and over lists; while loops that repeat until a condition changes; break and continue.
- Collections. Lists (ordered and changeable), tuples (ordered and fixed), dictionaries (key and value pairs, like a phone book) and sets (unique items). Dictionaries in particular are used everywhere.
- Functions. Defining your own with def, parameters, default values and return. Functions let you name a piece of logic and reuse it.
- Errors and exceptions. Reading a traceback from the bottom up, and handling expected problems with try and except, for example when a user types letters instead of a number.
- Files. Reading and writing text files with with open(...), which closes the file automatically.
- Modules. Importing from the standard library, such as random, math, datetime and pathlib. Python is famous for being "batteries included": many common tasks are already solved in the standard library.
Object-oriented programming with classes is the natural next step, but it is better learned after you are comfortable with functions and dictionaries.
Step 3: practise more than you read
Watching tutorials feels productive, but skill comes from writing code and getting it wrong. A useful ratio is at least as much time coding as reading or watching. Some practical habits:
- Retype every example and then change it. What happens if the list is empty? If the number is negative?
- Solve small exercises daily. Sites such as Exercism, Codewars and HackerRank offer graded problems with feedback.
- Explain your code out loud, line by line. If you cannot explain a line, you do not yet understand it.
- Read error messages fully. Python's messages are usually clear: NameError means a name is misspelled or not defined, TypeError means you combined values of incompatible types, IndentationError means the spaces are wrong.
- Revisit earlier topics after a few days instead of only moving forward; spacing out reviews makes knowledge stick.
Step 4: build small projects
Projects connect separate topics into real programs. Good beginner projects, roughly in order of difficulty:
- A number-guessing game in which the computer picks a random number and gives hints.
- A unit converter for temperatures, distances or currencies with fixed rates.
- A simple quiz that reads questions from a file and keeps score.
- A password generator using the secrets module, which is designed for security, rather than random.
- A script that sorts the files in your downloads folder into subfolders by type.
- An expense tracker that saves entries to a CSV file and prints monthly totals.
The last two are examples of the kind of automation that makes Python valuable in daily life: a few dozen lines can save hours of repetitive work.
Step 5: learn the tools around the language
Once the basics feel familiar, learn three supporting skills. First, pip, Python's package installer, which gives you access to hundreds of thousands of free libraries on the Python Package Index (PyPI). Second, virtual environments (the built-in venv module), which keep each project's libraries separate so they do not conflict. Third, Git, which records the history of your code and lets you publish projects on GitHub.
Common beginner mistakes
- Tutorial hopping: starting a new course whenever one gets hard. Finish one, then build.
- Mixing tabs and spaces: configure the editor to insert four spaces when you press Tab.
- Naming a file after a module, for example random.py. Python will import your file instead of the real module and produce confusing errors.
- Forgetting that input is text: "3" + "4" gives "34", not 7.
- Trying to learn everything at once: web frameworks, data science and machine learning can all wait until the core language is solid.
Where Python can take you
After the fundamentals, choose a direction. For websites, learn Flask or Django. For data, learn pandas for tables and Matplotlib for charts, usually in Jupyter notebooks. For machine learning, scikit-learn is the classic starting point. For automation, explore libraries that work with spreadsheets, PDFs and web pages. Whatever you choose, the same basics you learned first will be in every line you write, which is why taking the time to learn them properly is the best investment a beginner can make.