Python Fundamentals

Python Fundamentals

Feb 14, 2023   ·  2 min read

This article shares important context on some of the fundamentals of Python. I recommend coming to understand these concepts right away when you start learning, such as functions, classes, data types & structures, and modules & packages.

I use Pluralsight, an online education platform, to help me learn skills like Python faster and to track my progress. I highly recommend signing up for free to use their Skill IQ tests to assess your proficiency in Python and receive helpful feedback on what you should focus your learning on!

NOTE: This article was inspired by my much larger article on Learn How to Program in Python.


You can install Python onto your computer following these instructions. As a note, there are two major versions of Python that are in use today: Python 2 (legacy version) and Python 3. The older Python 2 is no longer actively maintained, but is still in operation due to the use of legacy applications from that time period. Python 3 is the recommended version of Python and is the version that is actively maintained today. 

As you start learning Python, there are important building blocks to be aware of, namely functions, classes, modules, packages, data types, and data structures. These topics are closely inter-connected with one another on their use-cases and how they operate. 


Functions:

A fundamental building block used across programming languages is the "function." Functions are just like what you might've learned about in some of your Math classes. A function is a pre-defined set of steps that takes an input and transforms it into a desired output. Python comes pre-equipped with built-in functions that are always available to you for solving common problems found in programming. You can also find more functions from modules and packages (more on this in the next section!) or you can create your own.


Classes:

A similar, yet different, building bock of the language is the "class." Classes serve as the essence of the object-oriented programming style in Python. Everything is treated as an "object" (i.e.,  A function, integer, list, etc.), every object has a "type," and every object type is created through the use of classes. A helpful distinction between functions and classes is that functions do specific things while classes are specific things

An object that belongs to a class is called an "instance" of that class. For example, the list data structure (see more on data structures below) is a class in Python. When we create a list, we have an instance of the list class.

Classes often have what are called "methods" built into them, which are functions that allow us to do things with instances of the class. For example, if I am working with an instance of the list class, I can use the method list.append() to add more items to that list! 


Data Types & Structures:

We use the above building blocks to work with and manipulate different data types and structures. Data types are common across programming languages and are simply forms of data like text (e.g., strings), numeric values (e.g., integers, floats, and complex numbers), and boolean values (e.g., true or false). Along with these data types, data structures are templates of how we can organize data in useful ways. 

Python comes with powerful data structures that cover ~80% of what you'll need for programming. The other 20% of use-cases can be met through data structures found in other Python modules/packages, such as the Pandas "dataframe." Included data structures are as follows:


Modules & Packages:

The last important building blocks that I want to mention are "modules" and "packages," which will lead us into our next section!  A module is a collection of related functions stored in a .py file. You can source that file into your various Python projects so that you can re-use those functions, as needed. A package is very similar, but the difference is that a module is a singular .py file, while a package is a collection of modules. 

If you found any of my content helpful, please consider donating
using one of the following options   Anything is appreciated!