What’s Python?

Python is a high level, object-oriented, general purpose programming language primarily used in data science and web development. Let’s break down what that actually means.

  • Python is High-Level
    • As opposed to a low-level language such as assembly, Python is high-level.
    • This means it abstracts many aspects of code to make it easier to program. It’s like writing in Modern English instead of hieroglyphics.
    • It includes an extensive library of built-in functions you may use to achieve your goals.
    • You don’t have to write specific, complicated commands directly for the CPU to read.
    • The code you write in Python is compiled or translated into a lower-level language. This is read by a “virtual machine” which translates the program into instructions your CPU can execute.
    • A virtual machine may be developed for any computing platform. This means code you write on Windows with an x86 Intel Processor will work on an M1 Mac and vice versa, since they both have Python VMs that can execute the compiled python.
  • Python is Object-Oriented
    • Object Oriented Design allows us to abstract a lot of concepts and think of things in terms of real-world objects and functions. You can create custom objects which have their own functions and attributes. Then you can do things with the objects and have them interact.
    • This will make more sense down the road.
  • Python is General Purpose
    • Python is mostly used for data science and web development. However, it can be used for anything from game design to android apps.

How it Works, Design to Execution

Before you can write a python application, you must first install Python on your computer. This is the software that can interpret or compile your python code into a format readable by a python virtual machine. Often we refer to this software as an SDK, or software development kit.

Next, you should have a code editor or Integrated Development Environment (IDE). Python comes with IDLE, a basic python code editor. For a more featured experience, consider Visual Studio Code, a more advanced code editor with many plugins. Finally, IDEs are feature packed tools designed to handle every aspect of coding. They may include advanced debugging tools, GUI (interface) builders, version control tools, code auto-completion, and much more. A popular Python IDE is PyCharm.

After you install Python and configure your favorite code editor, you write your code and Python compiles it.

The source code you write is compiled or translated into bytecode. Bytecode is a lower-level instruction set designed to be read by a Python Virtual Machine (PVM).

If you’re familiar with Java, this is the same way the Java Virtual Machine (JVM) works.

PVMs are developed for every major platform and operating system. Once the program has been compiled into bytecode, any device with a PVM can run it. This makes python a cross platform language, meaning it supports many platforms.

Advantages of Python

Python has several unique features that make it an attractive language over similarly featured options.

First, Python’s syntax (the way you write code) is very easy to use and learn. This makes it great for beginners.

Python isn’t a cluttered language like Java. For example, here is a comparison of a simple program that asks the user to input a message and reads it back to them.

First, here’s the Java version.

public class Main {
    public static void main(String[] args) {
        Scanner userInput = new Scanner(System.in);
        System.out.println("Please enter a message.");
        String message = userInput.nextLine();
        System.out.println("You typed: " + message);
        userInput.close();
    }
}Code language: Java (java)

Now look at the Python version.

message = input("Please type a message.")
print("You typed: ", message)Code language: Python (python)

What took 5 lines of code in Java (excluding imports and setup) can be achieved in just two with Python, with much shorter lines of code and no setup involved.

You’ll also note that the Java version above has many other characters or syntax rules. You have to enclose sections of code with curly braces, make sure each statement ends with a semicolon, declare classes, and define each variable type. You don’t have to do any of that in Python.

So now that you understand some of the advantages of Python, and how it works, continue to the next section, where you’ll set up Python and run your first program.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments