A1. Introduction to Python

How to Get Started With Python?

In this tutorial, we will walk through the process of setting up Python on your computer and then writing your first program.


Video: On how to install Python?

(Click on Image for Video)

Python Youtube Install


Python is a versatile programming language that can be used across various platforms such as

  1. Windows,
  2. macOS, and
  3. Linux, as well as being compatible with Java and .NET virtual machines.

Python is free and open-source, but additionally, it offers the advantage of being able to run on multiple platforms.

However, it is important to note that while many Linux and Mac systems may already have Python pre-installed, the version may not be up-to-date.

To ensure optimal performance, it is recommended to install the latest version of Python.


10xer.co Ad Sponsored

ⓘ Sponsored by 10xer.co

The Easiest Way to Run Python on vscode

Steps to install Vscode

  1. Download and install Visual Studio Code (VSCode) from the official website: Download VsCode

  2. Once VSCode is installed, open it and navigate to the Extensions tab on the left sidebar.

  3. Search for and install the “Python” extension by Microsoft. Once the extension is installed, open a new file in VSCode and

Install Python + Vscode

  1. Select “Python” from the language selection at the bottom right corner of the editor.

  2. Start writing your Python code and save the file with a .py extension.

  3. To run the code, open the terminal in VSCode by going to “View” > “Terminal” or using the shortcut (Ctrl + `).

  4. In the terminal, navigate to the directory where your Python file is located and run it using the command “python [filename].py”

  5. Your code will be executed in the terminal and the output will be displayed.

As shown below :

Install Python + Vscode


10xer.co Ad Sponsored

ⓘ Sponsored by 10xer.co

Install python Independently

  1. Go to the official Python website: Python Download

Install Python + Vscode

  1. Download the appropriate version for your operating system (Windows, macOS, or Linux).
  2. Once the download is complete, run the installer and follow the prompts to complete the installation process.
  3. To check if the installation was successful, open a command prompt or terminal window and type “python -V” this command will show you the version of python that you have installed on your machine.

Install Python + Vscode

5. If the installation was successful, you should see the version number displayed in the command prompt or terminal window.

Note: Some operating systems like Linux and macOS have python pre-installed, so you may not need to install it.

You can check the version of python by running the command “python -V” in the terminal.

Once you finish the installation process, you can run Python.


How to run python in terminal/interactive mode?

Python is run in intermediate with Python shell or the interactive mode, which will allow you to write python expression or commands without writing the full code.

Steps for Interactive mode

  1. Open a command prompt or terminal window and type “python” or “python3” (depending on your installation) and press Enter.
  2. This will launch the Python interpreter and display the prompt “»>” or “….” as shown below.

Install Python + Vscode

  1. At this prompt, you can type any valid Python code and press Enter to execute it. For example, you can perform calculations, define variables, and call functions.

You can also use built-in functions such as print() and input() to interact with the user.

  1. To exit the Python shell, type “exit()” or use the shortcut “CTRL + Z” on Windows or “CTRL + D” on Linux or Mac.

Immediate mode is useful for testing small pieces of code, experimenting with new commands and libraries, and troubleshooting errors in your programs.


10xer.co Ad Sponsored

ⓘ Sponsored by 10xer.co

Your first Python Program

Let’s begin by writing your first python program. As the tradition goes, every programmer should first start by writing hello-world program.

A “Hello, World!” is a simple program that outputs Hello, World! on the screen. Since it’s a very simple program or a simple command, it’s often used to introduce a new programming language to beginners.

Create a file named hello-world.py in your directory. and then write the following statement:

print("Hello, World!")

Then, run the file. You will get the following output. If you are using Vscode, click on the green triangle button or type “python hello-world.py” to execute the file.

Hello, world!

And there you go, your first program in Python. As you can see, this was a pretty easy task. This is the beauty of the Python programming language.

10xer.co Ad Sponsored

ⓘ Sponsored by 10xer.co