First Principles Python Part 0

Enrico Shippole
8 min readSep 16, 2021

--

A brief introduction to one of the most popular programming languages in the world, Python. Python is both consistent and clear, balancing ease of use, ease of learning, and power all into one programming language. This article is intended for absolute beginners who would like to understand more about the Python programming language and the information may be redundant for engineers already in the field. It will likely take time to become familiar with all of the topics and definitions discussed below, so try your best to hold off any feeling of initial overwhelmingness. As you continue learning, everything will begin to feel complete. A list of definitions will be updated here.

What Is Python?

Python is a strong, dynamically typed, high-level, interpreted, general-purpose programming and scripting language. Strong typing is when the type of value associated with the variable matters. The type should not change in an unexpected way through the duration of the program or while performing operations on that specific variable. Dynamically typed refers to runtime values having a type and that the type of variable is able to change during that runtime. High-level means there is a greater syntactic abstraction from the machine code or assembly languages needed to be read by the computer to perform instructions. Python is interpreted since the computer compiles the source code written by the developer into machine code the computer can understand during the execution of the program in the Python console. The name Python may also be used in reference to the Python interpreter, which is what compiles and executes the program. Objects, in Python, are things that possess associated attributes, data, and methods to interact with that object or class. As an example, an object could be a car that has a color, doors, windows, and price. You can interact with the car by driving, speeding up or slowing down, rolling down and up the windows, or even selling it.

Who Should Learn Python?

There are no expectations or previous requirements other than a willingness to learn and a bit of individual motivation to keep practicing programming consistently. Anyone can choose to learn Python, whether they are looking to become a software engineer, build complex artificial intelligence, or even just use programming to improve their day-to-day workflow. Python is also great for starting to learn general programming concepts, due to its inherent readability and explicit syntactical structure, which can be further built upon as you gain more familiarity with the language itself and programming knowledge. As you progress through more advanced topics you will be able to begin to apply your programming skills to solve real-world problems. While learning Python, I would recommend resisting the temptation to constantly look up answers to coding problems, using popular websites such as Stack Overflow, until you have dedicated enough time working through them and testing your code.

Why Program in Python?

Python is a free and flexible, general-purpose programming language that can be used in a wide range of different applications and multiple programming paradigms (functional, dynamic, or object-oriented). The Python programming language is easily accessible on different devices from desktops to micro-controllers and can run on almost every modern operating system (Windows, macOS, Linux). Python comes with its own pre-packaged console and integrates seamlessly with other developer environments and interactive consoles (IPython). It is the fastest-growing major programming language in the world due to its simplicity and readable design which makes it easy to start and learn as a beginner developer or engineer who may have never written code before. Python provides plenty of additional, free scientific packages and libraries (also called modules) which extend beyond its robust built-in standard library (see the section below) making it a very popular option for data analytics, data science, and machine learning. Python also has relative terseness making it possible to write programs that are more concise while still being equivalent to those written in other static languages. The language inherently possesses dynamic typing and memory usage which allows developers some syntactic leniency and to become productive faster while still having plenty of depth and design control. For these reasons, many academic institutions are swapping to Python as an introductory programming language over others such as Java or C/C++. The same fundamental theories and ideas can be applied in Python which also makes it easy for developers from other disciplines in computer science to pick up the language and quickly start programming. A developer who learned Java will be able to apply the same fundamental principles of object-oriented programming paradigms to Python.

Guido van Rossum

Who Created Python?

Python has existed since the 1980s and was developed by Guido van Rossum at Centrum Wiskunde & Informatica (CWI) in the Netherlands. Guido van Rossum named the language after the British comedy show, “Monty Pythons Flying Circus”. Python’s documentation contains references to the show. The Python Software Foundation, a nonprofit organization created in March 2001, currently manages the support for the Python programming language and will continue to provide updates and develop the distribution into the foreseeable future.

Python Standard Library (PSL)

One of Python’s greatest strengths is its built-in standard library which provides a useful collection of varying tools including modules for databasing, arithmetic and mathematical functions, graphical user interfaces, regular expressions, and testing. The modules consist of pre-defined methods, an object, which usually pertains to specific aspects of programming and incorporates functions for completely related tasks. Modules and packages will provide internal documentation providing specifications for how the code functions as well as test cases to cite errors that may occur during the execution of the program. You will also be able to develop and maintain your own modules and packages once you have enough of a programming background. The Python Package Index (PyPI), an official repository, contains almost 300,000 Python software packages for use.

Python Versions

There are two versions of Python, Python 2 created in October 2000, and Python 3 launched in December 2008. Python 2 will no longer receive support and had its last end-of-life updates in 2020. Programming languages change over time as new features are changed or added, and Python 3 provides significant revisions. It is likely that much of the code produced in Python 3 will not be transferable to and able to run properly in Python 2. I would recommend learning Python 3 as it will continue to be improved and supported into the future as well as many of its packages, libraries, and modules. Many of the code examples, tutorials, guides, and Colab workbooks provided will be compatible with earlier versions of Python going back to 3.6, and up to the latest version.

If you do not have Python 3.9 or another release version installed, please check out this quick and simple Python installation guide. Both Homebrew for Mac and the Windows Store provide additional alternative installers for Python as well. Any modern-day computer system should be able to run and install Python without any issues. You can check if you have Python correctly installed on your computer by typing python in a terminal or command prompt.

1. Open up the Command Prompt, a Linux Terminal, or macOS Terminal

Depending on your operating system you will have different command-line interface (CLI) applications for accessing, downloading, deleting, etc. files on your local machine. You will first need to open a CLI application and click into the interface and next to the listed file path: C:\YourFilePathHere>

2. Type python in the CLI

You can check if you have the latest version of Python installed by typing:

python

3. The Python Version is Outputted in the CLI

You can see the outputted version of Python in the terminal as well as additional terminal commands which provide more information.

Zen of Python

The Zen of Python was created by Tim Peters and goes as:

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.

Although practicality beats purity.

Errors should never pass silently.

Unless explicitly silenced.

In the face of ambiguity, refuse the temptation to guess.

There should be one– and preferably only one –obvious way to do it.

Although that way may not be obvious at first unless you’re Dutch.

Now is better than never.

Although never is often better than right now.

If the implementation is hard to explain, it’s a bad idea.

If the implementation is easy to explain, it may be a good idea.

Namespaces are one honking great idea — let’s do more of those!

Next Part

First Principles Python Part 1

Create a Python program, write code in a .py file, successfully compile a program without error, and output the text “Hello, World!” to the terminal here.

Additional Articles on How to Setup your Developer Environment

I would recommend starting here and installing an integrated development environment (IDE) for Python, as it will make managing your code or projects significantly easier. Popular IDEs are PyCharm, Visual Studio Code, Google Colab, and the Jupyter Notebook.

Integrated Developer Environments Part 1

Integrated Developer Environments Part 2

Anaconda Installation Guide

Python Installation Guide

If you found this article to be useful please share it with your peers.

Share

Or follow me on social media:

Substack

Medium

Twitter

Instagram

--

--