Should I Become a Freelance Developer?

Being a freelance developer is a new way of living in the 21st century: It’s a path of personal growth, learning new skills, and earning money in the process. But in today’s digital economy, becoming a freelance developer is – above everything else – a lifestyle choice. It can give you fulfillment, flexibility, and constant … Read more

What’s the Meaning of the Exclamation Mark in a Jupyter Notebook?

What many coders using Jupyter notebooks do not know is that Jupyter notebooks provide you the exclamation mark operator that allows you to execute commands on the underlying operating system. In Jupyter notebooks, the exclamation mark ! executes commands from the underlying operating system. For example, to run the list directory command ls in your … Read more

How to Check Python Version in Jupyter Notebook?

To check the Python version in your Jupyter notebook, first import the python_version function with “from platform import python_version“. Then call the function python_version() that returns a string with the version number running in your Jupyter notebook such as “3.7.11”. You can try this yourself in our interactive Jupyter notebook: Check Version Information Using sys … Read more

Python Version Aliases (Alternatives)

To check the Python version in your shell, you can use the following alternatives (aliases): Terminal: The following commands can be used to check the Python version in your terminal. Note that the first and second are aliases whereas the third one provides more information about the built. python –version python -V python -VV Note … Read more

What’s the Difference Between ‘py’ and ‘python’ in the Terminal?

Problem If you run Python in your terminal or shell, you may have realized that there are two ways to do so: using the “python” command and using the “py” command. What’s the difference? Example Say, you want to check your Python version. You can run both commands and the output is different! Here’s using … Read more

What Python Version is on Your Mac?

To check the default Python version on your macOS, use the command python –version in your terminal. In particular, use the following four steps to check the Python version on your Mac operating system. Press CMD + Space to open Spotlight. Type β€œterminal” and press enter. Execute command: type python –version or python -V and … Read more

The Art of Clean Code [Book Resources]

This page contains resources for my book “The Art of Clean Code” (NoStarch, 2022). You can check out the book here. Olivetti Faces Access the code in the Jupyter Notebook here: Life Expectancy Calculator Access the code in the Jupyter notebook here:

Python Print Octal Without ‘0o’

Problem Formulation If you print an octal number, Python uses the prefix ‘0o’ to indicate that it’s a number in the octal system and not in the decimal system like normal integers. However, if you already know that the output numbers are octal, you don’t necessarily need the ‘0o’ prefix. How to print oct numbers … Read more

Python Print Hex Without ‘0x’

Problem Formulation If you print a hexadecimal number, Python uses the prefix ‘0x’ to indicate that it’s a number in the hexadecimal system and not in the decimal system like normal integers. However, if you already know that the output numbers are hexadecimal, you don’t necessarily need the ‘0x’ prefix. How to print hex numbers … Read more

Python Print Binary Without ‘0b’

Problem Formulation If you print a binary number, Python uses the prefix ‘0b’ to indicate that it’s a number in the binary system and not in the decimal system like normal integers. However, if you already know that the output numbers are binary, you don’t necessarily need the ‘0b’ prefix. How to print binary numbers … Read more

How to Interleave Two Strings of Variable Lengths in Python?

Half an hour ago, my friend and coauthor of the textbook “Coffee Break NumPy” asked me the following question via WhatsApp: Problem Formulation How would you solve the problem of interleaving two strings in Python: Input: String s1= “AAA” and string s2 = “BBBBB” Output: String s=”ABABABBB” Being obsessed with finding the most Pythonic way … Read more