Python Notes: Introduction

  1. The information presented here is intended for educational use.
  2. The information presented here is provided free of charge, as-is, with no warranty of any kind.
Edit: 2021-11-07



Online dictionaries provide many definitions of the phrase "chopper" but one I remember most means "motorcycle". Where did this originate? Starting in the 1950s, motorcycle mechanics would chop off components (mirrors, fenders, etc.) to make the machine lighter for racing while also making it appear visually cleaner but not necessarily street legal. The resulting motorcycle was called a chopper which today seems absurd because that phrase should have been used to describe the person doing the chopping, not the final product. But hey, these people were not exactly word smiths.

When I started working on computers in the 1970s, computer enthusiasts were already known as hackers because they hacked off seemingly unnecessary parts of computer software so it would execute faster on the smaller (than a mainframe) computers of the day. Everyone around me seemed to know that computer "hacking" was derived from motorcycle "chopping" and still seemed the case in 1984 when Steven Levy published Hackers: Heroes of the Computer Revolution.

Hacking acquired a negative connotation when popular newsrooms associated "hacking" with the activity of "breaking into a computer" (then, usually connected to the telephone network since the popular internet did not yet exist).

Although the phrase "hacking" currently appears to be going through a positive up swing (see: Hackerspace) I think the phrase noodling has fewer negative connotations.

Hacking - Noodling with BASIC

Anyone who started playing with BASIC on personal computers in the 1970s and 1980s will recognize the importance of that language for noodling around. The creators of BASIC intended it to be used to teach computer programming concepts to FORTRAN students, but noodling around made BASIC ideal for teaching other concepts in science, engineering, and math. I am a huge fan of DFT-FFT books (especially these two: Understanding the FFT and Understanding FFT Applications by Anders Zonst of Citrus Press, Titusville, Florida) where the author provided hundreds of demo programs written in PC-BASIC (a generic term I am using for this article).

BASIC on personal computers of the 1970s was usually implemented in ROM, and every implementation was different (Apple2, TRS-80, HeathKit-H9). Starting with the IBM-PC in 1981, Microsoft, began publishing 16-bit software products like GW-BASIC (1983),  QuickBASIC (1985) and QBASIC (1991) which worked well on 16-bit operating systems like MS-DOS (1981) up through Windows-3.11 (1992). These 16-bit language interpreters were also supported on 32-bit operating systems starting with Windows-95 through to Windows-7 via a OS technique known as THUNKING.

The big problem today is that 64-bit computers run 64-bit operating systems, like Windows-10, where 32-bit programs are THUNKED but not 16-bit programs. Technical work-arounds exist including "setting up a virtual machine" on your 64-bit OS but why go to all that bother when all you want to do is noodle around? Perhaps it is time to ditch BASIC

Hacking - Noodling with Python

Many people reading this will not know that Python was first created in 1990 to replace BASIC. Today, Python is primarily used to do server-side scripting on the internet/world-wide-web but also has many other uses. Here is a short list:

  • popular in the scientific analysis of large data sets since the creation of a free third-party Python libraries known as NumPy and SciPy (just two of many)
  • popular in many financial circles after Wall Street programmers noticed (during/after the 2008 financial melt down) that many "business case" decisions were based upon "questionable data" produced from ad-hoc spreadsheet imports (some estimates questioned the investment decisions at somewhere between $500M and $1B). This was one of the reasons for the creation of a free third-party Python library known as Pandas which can import almost any spreadsheet format using only 5-6 lines of code
  • popular on almost every computer platform (Windows, Macintosh, Linux, UNIX, or others) for any purpose including noodling around because it is available free of charge -AND- appears to be more consistently implemented than BASIC ever was

Python does not have these BASIC imitations:

  • In BASIC, this statement PRINT 2^31 (two raised to the thirty-first power) fails with 32-bit signed integers (longword)
    • I have used more than a dozen different flavors of BASIC (on both minicomputers and microcomputers) and none of them supported unsigned integers.
  • In BASIC, this statement PRINT 2^63 fails with 64-bit signed integers (quadword)
  • Some modern BASIC implementations now support 128-bit signed integers (octaword) but most do not support exponentiation past 64-bits.

Python3 (which runs on a virtual machine) has no difficulty with these statements:

  • Typing PRINT(2**9999) (e.g. 2^9999) in the IDLE interpreter instantly yields 37x80+50 characters.
  • Typing PRINT(2**99999) (e.g. 2^99999) in the IDLE interpreter instantly yields a yellow alert with the phrase "Squeezed Text (377 lines)" which can be optionally display or copied to another app via the clipboard.
  • Typing PRINT(2**999999) (e.g. 2^999999) in the IDLE interpreter requires a few seconds to yield a yellow alert with the phrase "Squeezed Text (3763 lines)"

Imagine using numbers this size to access your data analysis arrays

my Example Programs

link description Notes
simple calendar a very simple calendar generator BASIC-to-Python conversion examples
pix-of-day picture of the day generator extracts a picture-of-the-day (along with some HTML) from a relational database (MySQL or Maria DB) which is then injected into a DIV by JavaScript.
click here to see it in action:
1) the top right corner will show a NASA chart for last month's CO2 readings
2) eight seconds later, the image and text will switch to something extracted from my database
3) eight seconds later the picture switches back to the CO2 readings
4) this will cycle back an forth for ten iterations
5) punch PF12 on your browser then click CONSOLE to observe logging messages 
dft-fft Discrete Fourier Transform - Fast Fourier Transform BASIC-to-Python conversion examples
dh standalone Diffie-Hellman key exchange demo (interactive) Python interactive standalone application
dh web Diffie-Hellman key exchange demo (web) Python web application (just to show you how)
compute the date of Easter for any given year it all starts with determining the date of the first full moon on, or after. the Spring equinox.
compiling caching Python compiling - Python file caching article for nerds

Shifting over to Python

Machine Learning

caveats: both machine learning and artificial intelligence have a lot of history going back to the 1940 and 1950s so contains a lot of non-computer terminology. Modern computer technologists wishing to learn more might wish to start here:

External Links

 Back to Home
 Neil Rieck
 Waterloo, Ontario, Canada.