Lesson 00-02: What is Python?

Python is a high level, general purpose programming language named after Monty Python, the British comedy group. What does it mean for a language to be “high-level”?

“High Level”

When you write some code, the computer doesn’t interpret it as the words you write. When computers receive instructions to do anything, like run an application, or even to respond to a keystroke, it receives instructions in machine code. Machine code is nearly unreadable by humans. It might look something like this:

Image of machine code

Pretty unintelligible, right? This is the lowest level of code there is. Code written in other languages have to be translated into machine code before being fed to the CPU - Central Processing Unit, or simply the Processor - the brain of the computer. Your CPU is the machine that handles all the calculations. Plus, machine code is different for each type of CPU! Having to write a different program for every type of computer you want it to work on is a lot of work you don’t want to deal with.

Assembly language is the staple example of a “low level language” - those who are familiar with it can read it and write in it, but it is still CPU-architecture dependent! A simple “Hello World!” program in Assembly language might look something like this (source):

 ;

        global  _start

        section .text
_start:
        mov     rax, 1
        mov     rdi, 1
        mov     rsi, message
        mov     rdx, 13
        syscall

        mov     eax, 60
        xor     rdi, rdi
        syscall
message:
        db      "Hello, World", 10

While it looks a little more understandable, it’s still pretty unreadable. When you write in high level languages, on the other hand, you don’t have to worry about what CPU architecture you’re writing for. It’s also more human-readable to make writing it easier. Here’s an example in C (a high level programming language):

#include <stdio.h>
int main()
{
    printf("Hello world!");
    return(0);
}

This looks much better - I recognize some words there. Then here’s “Hello World!” in python:

print("Hello World!")

Doesn’t get much simpler than that!

While high-level languages are easier to read, easier to write, and work across many platforms, they tend to be slower than low-level languages since there’s more happening behind the hood. However, modern technology is fast enough so that unless you really need to optimize your code for speed (like if you’re writing a game engine that does a lot of fancy graphics processing), you don’t have to worry about the speed differences.

Now we move onto how python is...

“Multi-purpose”

Python a pretty popular language used for many different things. Here’s just a few examples - You can use python to...

  • Scrape (automatically collect) data off the web!
  • Build fully developed websites! (examples: Google, YouTube, DropBox, Reddit, Instagram)
  • Build games! (full list here)
  • Run scientific and mathematical computations!
  • Automation - you can write scripts to automate your life!
  • And more!

Python is used for a fairly large variety of things! But most importantly, it’s a relatively easy language to pick up, which is why we use it in this course. We’ll be covering the basics of computer science and programming, and these concepts can be transferred to almost any other language. So you’re not just learning python - you’re learning computer science and programming.

Next Section - Lesson 00-03: Installing Python