DEV Community

Cover image for Python, for Javascript Devs
Justin Watson
Justin Watson

Posted on

Python, for Javascript Devs

My Story

I initially began learning Python in 2019 with the edX course, MITx: Introduction to Computer Science and Programming Using Python | edX. 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.

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 in addition to utilizing the Learn Python 3 | Codecademy 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

Conditional Statements

A code snippet of conditional statements in Python

Loops

A code snippet of Loops in Python

Math

A code snippet of the various math quirks in Python

Arrays, aka Lists

2D Arrays

Conclusion

This about wraps up the fundamental building blocks of Python and its unique characteristics. While Python offers powerful tools like the collections.deque and heapq 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.

Top comments (2)