Python Language Introduction


This entry is part 1 of 4 in the series Python

What is Python? Python is perhaps the fastest-growing programming language in the world, at the moment. It is an interpreted, high-level language that is also cross-platform and general purpose. It has a large community and a large ecosystem of libraries, frameworks, and tools. It has been around already for over 20 years. There are two versions of Python out there: 2 and 3. Version 2 is the legacy (old) version of Python that will not be supported past the year 2020. Python 3 is the version you will want to learn unless you need to support programs written in Python 2. Python 3.x is incompatible with Python 2.x.

Python is a multi-purpose language. This means that you can use it for data analysis, machine learning, web development, automation and more.

Python is cross-platform. It works on Windows, Mac, and Linux.

Python is a multi-paradigm language. What does this mean? We have a post on programming paradigms. Python is functional, object-oriented, imperative and reflective. It is a high-level programming language, meaning that it is not close to the hardware with a series of zeros and ones for the programmer to write.

Python is a dynamic language, not a static one. What does this mean? With a static language, like C++, C# or Java, when we declare a variable like first_name or age, we need to specify the type. Age would be an integer (or decimal) and the first name would be a string. With a static language, age will always be an integer, so if we later try to set age to “Bob”, the compiler will complain and will not run your code without giving you a message. However, Python is a dynamic language, just like JavaScript and Ruby. With dynamic languages, the type of a variable is determined not at compile time as just explained, but at run time. All we do is give our variable a name and assign a value to it. We can assign 26 to our variable age, and later assign “Robert” to age and the program will still run fine because the type changes to suit the data. The type is dynamic. Dynamic typing means variables can point to objects of any data type. Also, there are no default types for most new variables. So we need to assign, or initialize, before calling them. Just remember that if you want to modify the contents of a variable, you usually need to reassign it.

Python is an object-oriented language. We have the concept of classes. For example, in Python, if we have an integer called age, then age is an instance of the integer class. When we are working on our Python project, all we have to do is hover our mouse over the variable to see what the type is.

You import modules with Python. Suppose you want to import a math module. Write import math. You could also write import math as M and then use the factorial function in that library by typing something like print(math.factorial(3)).

The creator of Python didn’t name it after a snake. He named it after a British comedy troupe: Monty Python, because he wanted it to be easy and approachable.

Install Python on Windows

To install Python, go to their website at python.org. Click on the Downloads link. Click on the button that says Download Python. As of early 2020, the latest version is 3.8.2. Do not download version 2.x.x because it will not be supported in 2021. If you have successfully installed Python on Windows you should see something like the following from the command line. As of April 2024, the version I now get is 3.12.0.

.

To exit this console you can press Ctrl+Z and then Enter. Your version will likely be different. It’s now November 2024 and the version I see is 3.12.0.

Editor or Integrated Development Environment (IDE)?

Should you use an editor or an IDE? Either is fine. It’s a personal preference. An IDE is a code editor with some extra features such as autocompletion, debugging and testing. There are lots of options. For editors, you could use VSCode, Atom or Sublime or some other editor. For an IDE you could use PyCharm (a JetBrains product). You can convert the “simple” VSCode editor into a powerful Python IDE by installing an extension.

In a Jupyter notebook, you can check the version of Python you are running with code similar to the following. Suppose you need to be sure you are running at least version 3.7. Run the following code.

import sys
assert sys.version_info >= (3, 7)
Series NavigationResources for Learning Python >>

Leave a comment

Your email address will not be published. Required fields are marked *