Learn to program in Python

Síguenos / Follow us!


Python is a simple, easy-to-understand, and minimalistic language. It is one of the easiest programming languages to learn because it has a clean and readable syntax that makes it easy for beginners to read and use. Besides, Python is free and open-source.

Python is an interpreted high-level general-purpose programming. It is used for web development, AI, machine learning, operating systems, mobile application development, and video games.


First steps

In case you do not want to (or cannot) install Python on your computer, you can execute Python programs using online tools, such as Python.org, replit (Python online editor), and Pythontutor.

learn Python

Otherwise, open the terminal in your operating system and then open the Python prompt by typing python:

user@pc:~$ python
Python 3.9.5 (default, May 11 2021, 08:20:37) 
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello World")
Hello World
>>> 3*5 # You can use Python as a powerful calculator. The operators +, -, * and / work just like in most other languages.
>>> 5**2 # 5 squared
25 # 52=25
>>> s = 'supercalifragilisticexpialidocious'
>>> len(s) # The built-in function len() returns the length of a string.
>>> import this! # Python has a really good sense of humour
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
>>> quit() # Use quit() or Ctrl-D (i.e. EOF) to exit

Visual Studio Code

Install Visual Studio Code. It is a multiplatform source-code editor made by Microsoft. Visual Studio Code functionality can be extended using extensions.

Let's install Python extension for Visual Studio Code, Sublime Text Keymap (it imports keybindings and settings from Sublime Text to Visual Studio Code), Python-autopep8 (it automatically formats Python code. Linux's shortcut is Ctrl+Shift+I), Pylint (a Python code analysis tool which looks for programming errors, e.g., print myswap(5, 9) as you can see in the screenshot below), Code Runner, and One Dark Pro by opening the Command Palette (Ctrl+Shift+P) and typing Extensions: Install Extensions.

learn Python

Visual Studio Code provides an easy keyboard shortcuts editing experience using its Keyboard Shortcuts editor. You can open it by going to the menu File/Code, Preferences, Keyboard Shortcuts or using the Command Palette (Ctrl+Shift+P), Preferences: Open Keyboard Shortcuts.

Create an empty folder (mkdir python), navigate into it (cd python) and open VS Code (code .). Alternatively, you can launch VS Code, then go to the File menu and select Open Folder... to open the project folder.

Immediately after that, select a Python 3 interpreter by opening the Command Palette (Ctrl+Shift+P) and typing the Python: Select Interpreter command to search, then select the Python's version that you want to work with.

Create a Python source code file: File, New File. As you write Python code, Visual Studio Code may give you a warning: Linter pylint (a source code, bug, and quality checker for Python) is not installed. Click on Install.

Run your source code file. Click on the Run Python File in Terminal button in the top-right side of the editor.

learn Python

To run or debug an app, select Run and Debug on the Debug start view, Run, Start Debugging on the main menu, or just press F5, and VS Code will run your currently active file.

VS Code keeps debugging configuration information in a launch.json file. Navigate through Run, Open Configuration and you will be able to edit it. You may want to pass some arguments into the program by defining them in the args setting of launch.json as defined below:

    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "args":["myarg1", "myarg2"],
            "console": "integratedTerminal"

Let's configure Visual Studio Code to your heart's content.

Some resources: The Ultimate Python Resource Hub, w3Schools, The Algorithms, etc.

If you have this error: TabError: inconsistent use of tabs and spaces in indentation using VS Code. You may want to convert existing indentation from spaces to tabs by hitting Ctrl + Shift + P and type: Convert indentation to Tabs.

Compártelo / Share it!

Author: Anawim

I am a social activist. I have two Bachelor's degrees, Maths and Computer & Software Engineering. I also have a Ph.D. in Psychology. I have written nine published books, four scientific articles, and five scientific presentations. I simply want to contribute to making a difference where it counts, so that we make the world a better, more sustainable, prosperous, and fairer place. I am always willing to give free talks and lectures about the social problems that exist in our world today.

Leave a Reply

Your email address will not be published. Required fields are marked *