How to Embed a Python Interpreter in Your Website?

Want to make your website more interactive? Embed a Python interpreter into your website! Why? Because an embedded Python interpreter not only increases the interactivity and usability of your website — and creates happy users for your web business. It also increases the average time spent on your website because people will try out things. … Read more

How to Install Pip? 5 Easy Steps

In this article, I’ll quickly guide you through the installation steps for Python’s package installer pip. But first things first: πŸ‘‡ What Is Pip? βœ… pip is the package installer for Python used to install and manage software packages (also known as libraries or modules) written in Python. pip makes it easy to install, upgrade, … Read more

BrainWaves P2P Social Network – How I Created a Basic Server

Welcome back to the Brainwaves P2P project, or at least my take on it :-). The previous article was a theoretical explanation of how I envision this project. It is now time to start laying the groundwork! I learn as I go… As some of you might have guessed already, I’m a completely self-taught coder. … Read more

Find the Median Index in Python

🐍 Question: How to find the index of the median element in a Python list? Something like argmedian()? In case you need a quick refresher, I have written this tutorial on finding the median itself (but not yet its index): πŸ‘‰ Recommended: 6 Ways to Get the Median of a Python List Solution A multi-liner … Read more

Python Int to String with Leading Zeros

To convert an integer i to a string with leading zeros so that it consists of 5 characters, use the format string f'{i:05d}’. The d flag in this expression defines that the result is a decimal value. The str(i).zfill(5) accomplishes the same string conversion of an integer with leading zeros. Challenge: Given an integer number. … Read more

How To Extract Numbers From A String In Python?

The easiest way to extract numbers from a Python string s is to use the expression re.findall(‘\d+’, s). For example, re.findall(‘\d+’, ‘hi 100 alice 18 old 42’) yields the list of strings [‘100′, ’18’, ’42’] that you can then convert to numbers using int() or float(). There are some tricks and alternatives, so keep reading … Read more