Installation to execution in 10 minutes

Image for post
Image for post
Photo by CDC on Unsplash

Moving from simple command-line scripts to web app development is a big leap in our Python journey. There are a variety of framework options with; however, even the concept can be overwhelming if you’ve never worked with a web framework.

If you’ve found this article then you’re probably researching different Python frameworks and trying to decide which to invest in. Instead of suffering from analysis paralysis, take a leap of faith and jump into Flask with this guide.

The first step is the hardest to take, but the easiest to make .We’ll …

A crucial next step for budding Pythonistas

Image for post
Image for post
Photo by Laurens Derks on Unsplash

It’s natural to focus — and get stuck on — syntax, structures, and libraries when learning a new programming language. Especially if it’s your first language, learning how to manage an environment is normally filed away under blissful ignorance.

It’s possible (somewhat) to get quite far without tackling environment management, but once you hit a wall that requires it, you’ll be left looking at a disorganized system folder that can best be described as a cluster****.

To start building good habits early, introduce Python virtual environments. …

The spiritual successor to NodeJS

Image for post
Image for post
Photo by Blanca Paloma Sánchez on Unsplash

Dating back to Node.js creator Ryan Dahl’s 2018 presentation 10 Things I Regret about Node.js, the programming community was anticipating his latest creation. Fast forward to May 2020 and Deno — A secure runtime for JavaScript and TypeScript — has released version 1.0.

Node.js as a JS runtime environment has become an absolute backbone for technology stacks. Any time you see the letter “N” in a tech stack, such as MEAN, that’s most likely Node.

With great success comes longevity and with longevity comes legacy challenges, some of which are too deeply ingrained in the architecture to be addressed.

This is where Deno comes in. If you’re curious about the language, as a seasoned developer or a fledgling self-starter who learned JavaScript, it’s undeniably exciting to get started on something that’s this new. …

Learn to use the range() function

Image for post
Image for post
Photo by Annie Spratt on Unsplash

There are a variety of reasons to count backwards in a program. Maybe you want to iterate over a list starting from the end or simply want to display a countdown timer.

We have multiple options available to us and are going to introduce two of those options: manually modifying a counter variable and using the range() function.

Manually Counting

The most basic method of counting backwards is to use a counting variable inside of a while loop. We need three definitions in order to count backwards: the starting point, how to exit the loop, and how to modify the loop.

Let’s set up a countdown timer from 10 to 0. We identify that the counter starts at 10, exits at 0, and the counter will be reduced by one after each loop. …

Convert a list to evenly sized segments

Image for post
Image for post
Photo by Martin Woortman on Unsplash

The Challenge

Create a function that converts a list to a two-dimensional “list of lists” where each nested structure is a specified equal length.

Here are some example inputs and expected outputs:

# INPUT LIST: [1,2,3,4,5,6]
# OUTPUT: [[1,2,3],[4,5,6]]
# INPUT LIST: [1,2,3,4,5]
# OUTPUT: [[1,2],[3,4],[5]]
# INPUT LIST: [1,2,3]
# OUTPUT: [[1,2,3]]

Reviewing our examples, there are some important distinctions for scenarios where the list and chunk size do not perfect match up.

  • When the list does not evenly divide by the chunk size, the last index will be shorter than the evenly sized chunks. …

Use argparse to define script values

Image for post
Image for post
Photo by Cupcake Media on Unsplash

Python provides a native library for passing command-line values to scripts called argparse. With argparse, we can include variable values in the execution command instead of using input() to request the value mid-execution. This saves us time and more importantly allows script execution lines to be saved and conveniently used — either manually or automated.

If you’ve written any Python scripts that require one or two values via input(), then read on and consider implementing argparse to simplify the execution of your scripts. …

Python tutorial with code examples

Image for post
Image for post
Photo by Philipp Katzenberger on Unsplash

Whenever teaching programming, the analogy I use for copying a list is taking a photocopy. It’s a simple, visual example that everybody can relate to. But more importantly, the analogy has a major flaw — intentionally. Unlike a photocopy, there is an additional component to copying lists and any other complex data structure: shallow copying vs deep copying.

In this guide we’ll demonstrate both shallow and deep copying to highlight the difference. Shallow copying is a simpler process so we’ll provide three different techniques for doing so.

Starter Code

We’re going to need some initial starter code to get started. We’re defining a simple class with one attribute name. The __init__ method is executed when an instance of the class is created and the __repr__ method is responsible for defining when an instance of the class is printed. …

Reflections on wearing multiple hats

Image for post
Image for post
Photo by Alex on Unsplash

The last 24 months have been an interesting time. Filled with change, I’ve moved from Training to Professional Services, which has been redefined as Customer Success. I have one directive: make the customer successful. Hold my drink…

Pursuing this simple yet difficult goal, I find myself asking the same question over and over. Do I fish for the man or do I teach the man to fish? Well duh, dummy you teach them to fish. Except it’s not that easy because customers don’t want the small fish, they’re looking for whales.

Listening to Pulse 2018’s Great Debate: How Technical Should CSMs Be? I realized the answer, as any debate should illuminate, is somewhere in the middle. I’m fortunate to have complimentary skillsets — I’m not one-dimensional. …

Avoid floating point inaccuracies with fsum()

Image for post
Image for post
Photo by Crissy Jarvis on Unsplash

One of the first eye-blinking, brow furrowing experiences when learning Python is an inevitable floating point inaccuracy. We’d expect a computer to be precise and “get math right,” but it’s not so simple.

The Problem with Decimal Arithmetic

Let’s try and add 0.1 together three times and demonstrate the problem.

total = 0.1 + 0.1 + 0.1
print(total) # 0.30000000000000004

To make sense of this, we need to understand (and accept) that floating point arithmetic is used to store decimal values.

What is Floating Point Arithmetic?

Without getting too deep, the takeaway is that Python uses formulas to store decimals and this leads to occasional inaccuracies.

The same discrepancy comes up when we try to manually add our values in a loop or use the sum() function. …

Learn new techniques and optimize your existing code

Image for post
Image for post
Photo by calvin chou on Unsplash

Refactoring is the process of updating existing code while functionally remain the same. There are a variety of reasons for refactoring code including performance, readability, and future scalability.

Refactoring is an important part of any coder’s process, not just advanced developers. For the less experienced audience, refactoring code is an excellent opportunity to learn and practice new techniques. Level up from get it done to get it done correctly!

We’ll go over five easy ways to refactor your beginner Python code, explaining the benefits of each and showing before and after code.

Define Functions for Repetitive Tasks

The first and probably most important refactoring we can do is defining functions for repetitive tasks. A function is a defined set of statements that can be executed by using the function’s name — known as a function call. …


Jonathan Hsu

Top writer with 1M+ views. Follow me at and

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store