Backend••11 min read•7 views

Introduction to Python for Beginners: How to Install & Execute Code

Just want to learn Python? Read a complete explanation of why Python is so popular, the proper installation method, and a guide to running your first script.

Have you ever felt overwhelmed when you wanted to dive into the world of programming for the first time? Seeing complicated lines of code, semicolons that cannot be missed, and rigid writing rules often makes the enthusiasm for learning immediately fade. However, what if there was a programming language that was designed to be read and understood as easily as you read everyday English texts? That's where Python emerges as a hero for many beginners, as well as being the main weapon for professional software engineers all over the world.

This article was written specifically for those of you who want to start your journey of learning Python from point zero. We will not speak robotic language or confusing technical terms without explanation. Instead, we will slowly dissect the introduction of Python, why this language is so popular, how to install Python on various operating systems, and step by step running your first Python code.

Grab a cup of coffee, take a deep breath, and let's start exploring programming languages that can let you build anything—from simple web applications, to text summarization systems, to artificial intelligence.

What is Python? More Than Just a Big Snake

If you searched for "Python" in a search engine a few decades ago, what would probably come up were documentaries about giant reptiles. But currently, Python refers to one of the most popular high-level programming languages on earth.

Created by a Dutch programmer named Guido van Rossum and first released in 1991, Python was built with one main philosophy:code readability (code readability). Guido wanted to create a programming language that was not only functional, but also beautiful and easy to read by humans.

Unlike some other programming languages that require you to write a lot of code just to display one line of text, Python cuts out all that complexity. Python uses indentation (space at the start of a line) to define blocks of code, instead of curly brackets {} which often make code look messy. The result? Python code looks neat, minimalist, and very clean.

As a language that is general-purpose, Python is not locked to just one type of work. You can use it to create scripts small automations on your local computer, or use it as the backbone for large-scale systems that handle millions of users every day.

Why Should You Learn Python?

Perhaps you are wondering, amidst the many new programming languages that continue to emerge, why is Python still the favorite? Why are so many giant tech companies investing heavily in the Python ecosystem? Here are some reasonable reasons that make Python really worth mastering.

1. Human-Friendly Syntax

As mentioned previously, Python was designed for humans, not just machines. The syntax is very intuitive. If you want to print something to the screen, you just write print("Hello World"). Compare that to other languages ​​that might require three to four lines of boilerplate code just to do the same thing. This readability makes the process of debugging (debugging) much faster and less frustrating.

2. Giant Ecosystem and Library

Python has the tagline "batteries included". This means that when you install Python, you get thousands of built-in modules that you can use straight away without having to download anything else. Beyond that, the Python community has built hundreds of thousands of powerful third-party libraries.

Are you interested in building a machine learning system for leaf image classification using algorithms such as Convolutional Neural Networks (CNN) or Support Vector Machines (SVM)? There's TensorFlow, Keras, and Scikit-Learn. Interested in natural language processing (NLP) to create text summarization (text summarization) applications? You can use NLTK or SpaCy. Want to quickly create an interactive web interface to showcase your AI models? Streamlit is ready to help with just a few lines of code. The existence of this library makes the software development process very efficient.

3. Active and Solid Community

When you learn programming, you will definitely encounter dead ends. You will get an error message that you don't understand. This is where the Python community shines. Because the user base is so massive, almost every error that you might encounter has already been experienced by someone else, and the solution is already available on forums like Stack Overflow or GitHub.

4. Very Wide Career Opportunities

Mastering Python opens the door to a variety of promising career fields. You can become a Data Scientist, Machine Learning Engineer, Backend Web Developer, or Data Analyst. This flexibility is invaluable, especially if you are still in the career exploration stage and have not yet decided on a specific specialization.

Preparation Before Installing Python

Before we go to the Python installation stage, it's a good idea to understand a little about the computer environment we are using. Python can run smoothly on almost all modern operating systems: Windows, macOS, and Linux distributions.

One important thing to know is the Python version. Currently, the version being actively developed and used is Python 3. Python 2 was officially "retired" in 2020 and no longer has security support. Therefore, make sure you always download and install Python 3.x (e.g. Python 3.10, 3.11, or later).

Apart from that, make sure your internet connection is stable to download the required installer or packages. The size of the Python installer is not too big, usually only around 25 to 30 MB, so the download process won't take long.

Python Installation Step By Step Guide

Let's get into the technical part that often makes beginners feel nervous: installation. Don't worry, the Python installation process has now been made very user-friendly. Select the operating system you use in the guide below.

1. How to Install Python on Windows

For Windows users, the installation process is very similar to installing a regular app or game, but there is one crucial check box that should not be missed.

  1. Download Installer: Open your browser and visit the official Python site at python.org/downloads. This website is smart enough to detect that you are using Windows and will immediately present a download button for the latest version.

  2. Run the Installer: After the .exe file has finished downloading, double-click to run it.

  3. Crucial Step (Attention!): On the first screen of installer, before you click the "Install Now" button, look at the very bottom. There will be a checkbox that says "Add Python 3.x to PATH". You MUST check this box. If you miss it, your computer will not be able to recognize the python command when you try to run it via Command Prompt later.

  4. Start Installation: Once the PATH box is checked, click "Install Now". Wait for the progress bar to run until it's finished.

  5. Verify: To make sure Python is installed correctly, open the Command Prompt (press the Windows key, type cmd, and press Enter). In the black window that appears, type python --version then press Enter. If the screen displays the Python version (e.g. Python 3.11.4), congratulations! Python has officially become a new resident on your Windows.

2. How to Install Python on macOS

macOS actually comes with Python built-in, but it's usually the older version used by Apple's internal operating system. It is highly recommended to install a new version of Python so as not to interfere with the built-in macOS system. There are many ways, you can use an official installer or a package manager like Homebrew or even via a local container like Orbstack. We will discuss the most common methods.

  1. Using the Official Installer: Just like Windows, visit python.org/downloads. Download the .pkg package for macOS. Open the file and follow the installation guide. You just need to keep clicking "Continue", agree to the license, and click "Install".

  2. Verification: Open the Terminal application (can be searched via Spotlight by pressing Cmd + Space then typing Terminal). Type the command python3 --version then press Enter. Note that on macOS, we often have to use the command python3 (using the number 3) to distinguish it from the system's default version. If the Python version appears, the installation was successful.

3. How to Install Python on Linux

If you use Linux, Python is most likely installed automatically. Most Linux distributions (such as Ubuntu, Debian, or Fedora) rely heavily on Python for various system tools.

  1. Open your Terminal.

  2. Try to check whether Python 3 already exists by typing: python3 --version.

  3. If it turns out it doesn't exist yet or the version is too behind, you can install it via your default Linux package manager. For Ubuntu or Debian users, run this command:

    Bash
    sudo apt update
    sudo apt install python3
    
  4. The system will ask for your administrator password. Enter the password, press Enter, and wait until the package installation process is complete.

Running Python: Start Writing Your First Code

Installation is complete, so what next? Having Python on your computer is like having a well-stocked kitchen; You haven't made anything until you start cooking. There are several different ways to interact with Python and run your code. Let's discuss it from the simplest to the more sophisticated.

Interactive Mode (REPL)

The quickest way to try Python is through interactive mode. REPL stands for Read-Evaluate-Print Loop. This is an environment where you type a line of code, press Enter, and Python will immediately provide the results that second. This is great for a quick logic test or trying out a new feature.

How to run it:

  1. Open Command Prompt (Windows) or Terminal (macOS/Linux).

  2. Type python (or python3 on macOS/Linux) and press Enter.

  3. The screen display will change. You will see Python version information and a prompt in the form of three larger symbols >>>. This means that Python is waiting for your command.

  4. Let's try a simple math operation. Type 5 + 10 then press Enter. Python will immediately print the number 15.

  5. Now let's say hello to the world. Type print("Hello, Python world!") and press Enter. The screen will display the text.

  6. To exit this mode, type quit() and press Enter, or press the key combination Ctrl + Z (in Windows) or Ctrl + D (on macOS/Linux).

Using Text Editor and Scripting Mode

Interactive mode is great for experimentation, but if you want to create a real application (like a web portal or a long automation script), you can't possibly type the code one by one every time you run it. You need to save your code in a file.

  1. Open any text editor application. You can use Notepad (although not recommended for the long term), or better yet use a modern code editor such as Visual Studio Code (VS Code), Sublime Text, or Cursor.

  2. Type the following lines of code into the text editor:

    Python
    name = "Great Programmer"
    print("Welcome, " + name)
    print("Let's start building amazing apps.")
    
  3. Save the file with the extension .py. For example, save it as hello.py. Make sure you know in which folder you saved this file (for example in the Documents folder).

  4. Reopen your Terminal or Command Prompt.

  5. Navigate to the folder where you saved the file using the command cd. Example: cd Documents.

  6. Run your Python file with the command: python hello.py (or python3 hello.py).

  7. You will see the results of your code execution printed on the terminal screen!

Next Level: Getting to Know the Virtual Environment

As an addition to this article—something that will save your life when you start creating more complex projects—let's talk a little about Virtual Environments.

As you start exploring Python further, you will definitely download various libraries from the internet using a tool called pip (Python package manager). For example, today you create project A that requires the NLTK version 3.5 module. Next month, you create project B which requires the same modules but version 3.8. If you install them all globally on your computer system, these versions will conflict and break your code (dependency hell).

Virtual Environment is the solution to this problem. This is like creating “isolated rooms” for each of your projects. Project A has its own room with its libraryinstallation, and Project B also has its own room, so they won't interfere with each other.

To create a virtual environment, you can navigate your terminal to the project folder, then run:

python -m venv environment_name

Then, you have to activate it.

  • On Windows: environment_name\Scripts\activate

  • On macOS/Linux: source environment_name/bin/activate

Once enabled, you will see your environment name in brackets to the left of the terminal prompt (example: (environment_name) C:\>). Now, all the packages you installed using pip will only be nested inside this project, keeping your computer's main system clean and tidy.

Conclusion: Your First Step Toward Innovation

Learning Python is one of the best investments you can make for your career development in this digital era. With easy-to-understand syntax and an incredibly large community, the barrier to entry into the world of programming is much lower.

In this article, we have dissected what Python is, why it is so essential, how to prepare your computer and install it, and how to run Python code from scratch.  Start practicing with basic concepts such as data types, branching (if-else), loops (for and while), to function. Keep watching Embuncode because it will update the next article... Don't be afraid to try, don't be afraid to see the error message, because every error is the best teacher in the world of software engineering. 

Sigit Wasis Subekti

Sigit Wasis Subekti

Software Engineer & Tech Educator

Software Engineer and Tech Educator sharing insights on web development and software architecture.