Python, for Javascript Devs
Tags: webdev, javascript, python
Published: 2024-06-28 18:53:44


## My Story

I initially began learning Python in 2019 with the edX course, [MITx: Introduction to Computer Science and Programming Using Python | edX](https://www.edx.org/learn/computer-science/massachusetts-institute-of-technology-introduction-to-computer-science-and-programming-using-python). This was my first foray into programming beyond the front-end technologies I knew, that being HTML and CSS. It was challenging, to say the least. Shortly after, I shifted my focus towards Web Development by enrolling in a coding bootcamp, which focused more on my previous foundation of HTML and CSS, as well as adding JavaScript into the mix.

  

## What Python can do for you

![A graph of various programming languages and their popularity from 2002 to 2024.](https://lh7-us.googleusercontent.com/docsz/AD_4nXezPsS8jRgkrc3jekqGzMCR92q9X0mpGRjwjnKDVe61y-sXh0vVfwzro_4VG6Fu6-pxSDlGa3yyqDrKV66QtFtJ42EnSQt-CIBXO5nOZOrXanq-ttnOe_7QZtUiG2-qp_qdD2KqwO1t6rXXDkwSLXufs9C6?key=u2IDCQP4e76FE2tN4xZLHA)

Python was the TIOBE Index language of the year 2020 and 2021. It is the #1 language of June 2024, as it was in June 2023.

  

Learning Python expands a programmer's toolbox, showcases curiosity, and can reveal hidden aptitudes and interests a developer didn’t know they had. Its minimalistic approach lends itself to developers being able to apply Python in no time, even more so if they already have a foundation in another programming language. While Python is largely known for its usage in the Data Science space, Python can also be combined with the django or flask frameworks for web development or be used for automation and scripting, potentially replacing Shell scripts in certain use cases.

 
## The Nitty Gritty

Python, like any programming language, has certain traits and quirks regarding how it works that may differ from what you’re used to. Let’s briefly go over how Python works under the hood so we can have more context for what’s to come.


Python is a programming language that is:

-   Interpreted: Python is executed line by line, rather than being compiled into machine code all at once. The official Python website goes with the term "interpreted". Although Python is technically both compiled and interpreted, this distinction is beyond the scope of this blog and not something to be concerned about for now.
    
-   Object-oriented: This means that Python code is organized into objects, which can have their own properties and methods. This makes it easy to create complex and reusable code.
    
-   High-level: This is just a fancy term to say Python code is written in a way that is similar to human language, rather than machine code. We’ll see this demonstrated in the code snippets later on.
    
-   Dynamically typed: Python variables do not have a fixed type. Their type is evaluated at runtime, so a variable of type int can become a string, and so forth. This makes it easy to write flexible and adaptable code but can also lead to some unpredictable outcomes.
    

## My approach to learning Python

As someone familiar with JavaScript, the best way for me to learn Python was to focus on its specific quirks and under-the-hood mechanisms. To gain a deeper understanding of Python, I relied heavily on the [Python documentation](https://docs.python.org/3/) in addition to utilizing the [Learn Python 3 | Codecademy](https://www.codecademy.com/enrolled/courses/learn-python-3) course. Documentation might seem like an old- school way to go about learning coding in an era where websites like Codecademy or freecodecamp are available at a moment’s notice, but I felt this was the best way to uncover Python's inner workings and truly comprehend how it functions. Taking the time to understand behind- the- scenes aspects of a language will level up your programming so much more.


Now, let's look at the syntax.

## Variables

![A code snippet of variables in Python](https://lh7-us.googleusercontent.com/docsz/AD_4nXetZY8PIyUy2e6HSq1h1ycOqRodf8kdrP4pVHOpq7iAIWTImLpifDewt0Gss_mNAL2O0nktavUajPQ3CdvUi_Rtv4m1DixRgeqk-A0vKqXjCMW9SrG21vlgRVMFeQny7uvVaOXeGDsacguOhUURQCYYX5NK?key=u2IDCQP4e76FE2tN4xZLHA)

  

## Conditional Statements

![A code snippet of conditional statements in Python](https://lh7-us.googleusercontent.com/docsz/AD_4nXcGxcEQh6fvDwNFETqhdCeR28mtzbrdjxuJXZ8N1QNnatKZ9LbXGVMnyGjTzO-a5e7ZsfU8mbR9VnM-dfvp0wkjZUl2TyemuonnIJVr4tEI0Q2v0CktLJaCLvJbVAUkLLhAPXUMt4oRgnXk09DQH9nM3wxT?key=u2IDCQP4e76FE2tN4xZLHA)

 
## Loops

![A code snippet of Loops in Python](https://lh7-us.googleusercontent.com/docsz/AD_4nXdoVoLXgsJiGrBDTPha_DW5gTcvMPABePm9jzg_kyqHgiwSyk7g8B19s7MlkuL9o0nX7WT-6uWXcpy42RS91cXdQOGZVeSbgNkti-plFeTkA500-FPPjUpVzbjzfnbC5Fd9mF6OP3_tCdVlfcNX46zSU18n?key=u2IDCQP4e76FE2tN4xZLHA)

## Math

![A code snippet of the various math quirks in Python](https://lh7-us.googleusercontent.com/docsz/AD_4nXcL5jrGpbeXs_JCxPbVPgFJ_5BdWzGXTbTE1ZzG3e2ok4-lt3oIpSSaaa8pJhnCS_QNA4h-qS0Vn40I3vn3kcJnpfBqc4Xad49kK-DaFiEsTR-LL_SqCNS8S8OR-CXlmc9gvFra2Mp4AyomAV8AeBkKXHWl?key=u2IDCQP4e76FE2tN4xZLHA)

## Arrays, aka Lists

![](https://lh7-us.googleusercontent.com/docsz/AD_4nXdGZz3tpeMVw3fzWt2hYXc3X14J9I0CWzKpW1TtwcDXLGTaF8CkU1PHurQQNbEIl1T1XjG1S1NEPogmQzsHM_9KqBIcJNO3HYMuB_QTtO5UH8U5_FxAqjoHwUxN8bc72Em49yX5-vq0nUngnvwxJxe2mxDC?key=u2IDCQP4e76FE2tN4xZLHA)

## 2D Arrays

![](https://lh7-us.googleusercontent.com/docsz/AD_4nXeUrVIh0rxp69la1-XtgxyXMkPqCEBNMLu82P3XTYAL7OBP3XCKrio5xrNK5-nywyKl7mZtjIWPBMDfS1Zm0DhWNj1MGjbdPsYLyv2Y0z-3XQfk3Wfyvekira5ux4NORx_nTsfx4_6H8IRCark6dKD7-7Y?key=u2IDCQP4e76FE2tN4xZLHA)

  

## Conclusion

This about wraps up the fundamental building blocks of Python and its unique characteristics. While Python offers powerful tools like the [collections.deque](https://docs.python.org/3/library/collections.html#collections.deque) and [heapq](https://docs.python.org/3/library/heapq.html) module to easily implement stacks, queues, and priority queues, exploring these in detail is beyond the scope of this introductory blog post. I encourage you to continue exploring the language (or begin your journey if you haven't already!) to uncover all that this amazing language offers. Thank you for reading.