Python

Python is a general-purpose programming language, which means it can be used for a wide range of applications, including web development, data science, artificial intelligence, machine learning, automation, scientific computing, and more. Python’s simplicity, readability, and versatility have contributed to its widespread adoption in both the development community and various industries.


Official Documentation


Features

  • Object-Oriented Programming (OOP): Python supports object-oriented programming (OOP) principles, allowing developers to use classes and objects to structure their code.

  • Interpreted and High-Level: Python is an interpreted language, meaning that the source code is executed line by line, making it easy to test and debug. It is also considered a high-level language because it abstracts many low-level details, making it more readable and easier to learn.

  • Dynamic Typing: Python is dynamically typed, which means you don’t need to explicitly declare the data type of a variable. The interpreter determines the type during runtime.

  • Indentation and Readability: Python uses indentation (whitespace at the beginning of a line) to define blocks of code. This indentation-based syntax enforces a clean and readable code structure.

  • Extensive Standard Library: Python comes with a vast standard library that includes modules and packages for various tasks, from working with files and networking to handling regular expressions and more. This helps developers avoid “reinventing the wheel” for common functionalities.

  • Versatility and Portability: Python is platform-independent, meaning Python code can run on various operating systems without modification. This portability makes it an excellent choice for cross-platform development.


Key Releases

There are two major versions of Python currently in use:

  • Python 2: Python 2 was the original version of Python and was released in the early 2000s. It gained widespread popularity and was used for many years in various projects and applications. It reached its end-of-life on January 1, 2020. This means that no official support, including security updates, bug fixes, or other improvements, are provided by the Python Software Foundation. In Python 2, strings are ASCII by default, and handling Unicode required additional considerations. There are some other semantic differences as well.

  • Python 3: Python 3 was released as a significant improvement over Python 2, addressing various design flaws and providing a more modern and consistent language, as well as improved security and performance. Python 3 is not backward compatible with Python 2 - This means that code written for Python 2 may need modifications to run on Python 3. There were also other various syntax improvements and changes to the standard library. These changes aimed to make the language more readable, consistent, and efficient.


Getting Started

There are several steps you can take to begin learning and using the language. Here’s a step-by-step guide:


  1. Download Python

    Visit the Official Python Website and download the latest version of Python.

  2. Installation

    Follow the installation instructions for your operating system. Make sure to check the box that says "Add Python to PATH" during installation for easier command-line access.

  3. Choose an Integrated Development Environment (IDE)

    You’ll then need to select an IDE or a text editor to write your Python code.

    Some popular options include:

    • Visual Studio Code: A lightweight and extensible code editor with Python support.
    • Sublime Text:
    • Atom:
    • PyCharm: A more feature rich IDE specifically for Python.
  4. Write Python Code

    Simply create a new Python source file (typically with a .py extension) using your chosen IDE or text editor, and write your C++ code using the C++ syntax and features!

    Here’s a simple “Hello, World!” program:

     print("Hello, World!")
    

    Yeah… it’s that easy!

  5. Save

    Save your Python code with a meaningful filename and the .py extension.

  6. Run the Code

    Use the command-line interface or the terminal to run your python code. Run the program by navigating to the folder with your file and typing:

     python hello_world.py
    

    OR (on some systems)

     python3 hello_world.py 
    


That there is no requirement to compile it like for other languages (such as C++). Because Python’s code is executed directly by an interpreter without the need for a separate compilation step.



Author: JDSherbert

Published: 28/12/2023


Table of contents