Optimizing the Two Sum Problem: Techniques, Trade-offs, and Performance
December 13, 2024
The Problem Statement One of the classic algorithm problems frequently encountered in interviews is the Two Sum problem.
Read More
Python 3.13 No-GIL Mode: How to Unlock True Multi-Threading and Boost Performance
November 1, 2024
Python 3.13 has quietly introduced a game-changing experimental feature: no-GIL mode!
Read More
Poetry vs Pip: Comparing Python Dependency Management and Packaging Tools
September 13, 2024
Poetry and Pip are two popular tools for managing Python dependencies and packaging Python projects.
Read More
Creating a Docker Alternative in Python
August 26, 2024
Docker is a popular containerization platform that allows developers to easily package applications into lightweight containers that can run isolated on any system.
Read More
Everything you need to know to Master API Creation
May 31, 2024
Introduction to APIs An API (Application Programming Interface) is a set of rules and protocols that allows different software applications to communicate with each other.
Read More
A Deep Dive into Machine Learning Algorithms
October 28, 2023
Machine learning algorithms are the backbone of modern artificial intelligence. They enable computers to learn and make predictions or decisions without being explicitly programmed.
Read More
How to Programmatically get Amazon IP Ranges/CIDRs
October 11, 2023
Amazon Web Services (AWS) operates an extensive network infrastructure with a vast number of IP addresses and CIDR blocks.
Read More
Programming Languages Series
October 2, 2023
1. Introduction Welcome to our Programming Languages Series! In this series, we’ll explore various programming languages, understand their purposes, provide code examples, and discuss when to use each one.
Read More
How to add Payment Subscriptions with Stripe in Django
August 31, 2023
Integrating Stripe subscriptions into your Django site involves several steps. Here’s a high-level overview of the process.
Read More
[Solved] A Number After a Double Reversal in Python
August 22, 2023
The problem Reversing an integer means to reverse all its digits.
Read More
Nature-Inspired Problem Solving: Genetic Algorithms
July 19, 2023
Introduction Genetic Algorithms (GAs) and Evolutionary Computation (EC) are powerful optimization techniques inspired by the process of natural selection and evolution.
Read More
Python Dynamic Programming: Mastering Optimization
July 18, 2023
Introduction Dynamic programming is a powerful algorithmic technique that allows developers to tackle complex problems efficiently.
Read More
Python Reflection & Metaprogramming: Advanced Power
July 17, 2023
Introduction Python is a versatile programming language that offers powerful features and capabilities.
Read More
Python Context Managers Mastery: Resource Management
July 10, 2023
Introduction Python context managers provide a convenient and reliable way to manage resources and ensure proper setup and teardown actions.
Read More
Python Decorators Mastery: Advanced Usage Guide
July 9, 2023
Introduction Python decorators are a powerful feature that allows you to modify the behavior of functions or classes dynamically.
Read More
Python's Yield Mastery: Advanced Usage Guide
July 8, 2023
Introduction Python’s yield statement is a powerful feature that allows you to create generator functions.
Read More
Python: Unleashing the Power of Simplicity and Versatility
July 7, 2023
Getting Started with Python Python is a versatile and popular programming language known for its simplicity and readability.
Read More
Python's Advanced Features: Empowering Programmers
July 6, 2023
Introduction: In the vast realm of programming, Python stands tall as a language that caters to developers of all levels.
Read More
Python's Yield: Unleashing Generator Magic
July 5, 2023
Introduction Python, being a versatile language, offers numerous tools and features to streamline our coding experience.
Read More
Python vs Java Performance: Programming Powerhouses
June 29, 2023
In the vast landscape of programming languages, Python and Java have emerged as titans, offering robust solutions for a wide range of applications.
Read More
Teach me the Basics of Data Science in Python
June 28, 2023
An overview of Data Science in Python This is an overview of the basics of data science in Python.
Read More
How to Generate Terraform using Python
June 22, 2023
To generate Terraform code using Python, you can utilize the power of the language and various libraries to dynamically create and manipulate the Terraform configuration files.
Read More
Create DynamoDB Table & Add Items using Python 3 from Lambda
June 13, 2023
To create a DynamoDB table and add items to it using Python 3 from AWS Lambda, you can use the AWS SDK for Python, also known as Boto3.
Read More
How to create a Site-to-Site VPN in Boto3 Python
June 12, 2023
To create a site-to-site VPN using the Boto3 library in Python, you can utilize the boto3.
Read More
Golang vs Python: The Ultimate Battle in DevOps
May 27, 2023
In the world of DevOps, two programming languages are often pitted against each other: Golang and Python.
Read More
Why DevOps and Python are Amazing Together
May 26, 2023
In today’s software development world, DevOps and Python are two of the most essential elements for building high-quality software.
Read More
Python & DevOps: Transforming Software Development
May 25, 2023
Introduction: In recent years, the software industry has witnessed a remarkable shift towards DevOps and Python.
Read More
How to Learn Recursion by Example in Python
April 5, 2023
Here’s an example code in Python that demonstrates recursion: def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) print(factorial(5)) # Output: 120 This code defines a function factorial that calculates the factorial of a given number n.
Read More
What is the Zen of Python?
March 30, 2023
The Zen of Python is an Easter Egg that long time Pythoneer (Tim Peters) channeled the guiding principals for the language’s design principals into 20 aphorisms, of which only 19 of them are written down.
Read More
How to Create a Password Generator in C++
March 27, 2023
You can easily create a password generator in C++ with the following simple method.
Read More
How to read user input as numbers in Python
March 23, 2023
In Python 3 onwards, the input function returns a string type.
Read More
Capitalize First Letter of Each Word in Python
March 22, 2023
If you have a sentence containing multiple words, and you want each of the words to start with a capital letter, then you can do one of the following:
Read More
How to Create a Password Generator in Python
March 16, 2023
You can easily create a password generator in Python with the following simple method.
Read More
How to Convert Bytes to a String in Python
March 14, 2023
If you need to convert bytes to a string in Python, then you can do the following:
Read More
How to measure the elapsed time in Python
March 13, 2023
Option 1 - using the time module import time start = time.
Read More
How to get the SHA512 sum of a string using Python
March 2, 2023
If you need to get the SHA512 sum of a string using Python, then you can do the following.
Read More
How to get the SHA256 sum of a string using Python
March 1, 2023
If you need to get the SHA256 sum of a string using Python, then you can do the following.
Read More
How to get the MD5 sum of a string using Python
February 28, 2023
If you need to get the MD5 sum of a string using Python, then you can do the following.
Read More
[Solved] TypeError: datetime Not JSON Serializable
February 27, 2023
If you get the following error: TypeError: Object of type datetime is not JSON serializable
Read More
Zip & Encode Dict to String & Back in Python
February 22, 2023
If you have a Python dictionary, and want to encode it as a string and zip it to save space, perhaps for passing a dictionary through as an environment variable or similar, then you can do the following
Read More
How to Generate a Random Number between 2 numbers in Python
February 16, 2023
If you need to generate a random number between two (2) numbers in Python, then you can make use of the random module.
Read More
How to find the Product of Consecutive Fib Numbers in Python
February 10, 2023
0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5, 0, 2, 6, 5, 4, 0, 5, 3, 0, 3, …
Read More
How to Solve Van Eck's Sequence in Python
February 9, 2023
0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5, 0, 2, 6, 5, 4, 0, 5, 3, 0, 3, …
Read More
How to Solve: Help the Bookseller Challenge in Python
February 8, 2023
A bookseller has lots of books classified in 26 categories labeled A, B, … Z.
Read More
How to Find the Stray Number in Python
December 10, 2022
The challenge You are given an odd-length array of integers, in which all of them are the same, except for one single number.
Read More
How to Empty and Delete an S3 Bucket using the AWS CLI
November 9, 2022
Option 1 – Using AWS CLI Step 1 export bucketname='your-bucket-here' Step 2
Read More
How to Calculate Variance in Python
November 7, 2022
If you need to calculate variance in Python, then you can do the following.
Read More
How to Calculate the Sum of a List in Python
November 6, 2022
If you need to calculate and get the sum of a list in Python, then you can do the following.
Read More
How to add a List to a Set in Python
November 5, 2022
If you need to add a list to a set in Python, then you can do the following:
Read More
How to Remove Punctuation from a List in Python
November 4, 2022
If you have a Python list, and want to remove all punctuation, then you can do the following:
Read More
How to Normalize a List of Numbers in Python
November 3, 2022
If you need to normalize a list of numbers in Python, then you can do the following:
Read More
How to Multiply a List by a Scalar in Python
November 2, 2022
If you need to multiply a list by a scalar in Python, then you can do one of the following:
Read More
How to Find the Index of the Minimum Element in a List in Python
November 1, 2022
If you need to find the index of the minimum element in a list, you can do one of the following:
Read More
How to Convert a Set to a String in Python
October 31, 2022
If you need to convert a set to a string in Python, then you can do one of the following:
Read More
How to Create Zip Archive of Directory in Python
October 29, 2022
If you need to create a zip of a directory using Python, then you can do the following:
Read More
How to Print Multiple Arguments in Python
October 24, 2022
If you need to print out multiple arguments using Python, then you can do one of the following:
Read More
How to Parallelize a for Loop in Python
October 2, 2022
If you need to run a for loop in parallel, then you can do one of the following:
Read More
How to Reverse an Integer in Python
October 1, 2022
If you need to reverse an integer using Python, then you can do the following:
Read More
How to Save a Python Dictionary to a File in Python
September 30, 2022
If you need to save a Python Dictionary object type to a file using Python, then you can do one of the following:
Read More
How to Move Files From One Directory to Another Using Python
September 29, 2022
If you need to move files from one directory to another directory, using Python, then you can do one of the following:
Read More
How to Get the Number of Lines in a File in Python
September 28, 2022
If you need to get the number of lines in a file, or the line count total from a file, using Python, then you can use one of the following options:
Read More
How to Read Specific Lines From a File in Python
September 27, 2022
If you need to read a specific line from a file using Python, then you can use one of the following options:
Read More
How to Get All Files in a Directory in Python
September 26, 2022
If you need to get all the files in a directory using Python, then you can do the following:
Read More
How to Check Operating System in Python
September 24, 2022
If you need to check the Operating System information from Python, then you can do one of the following:
Read More
How to Convert Hex to Byte in Python
September 23, 2022
If you need to convert Hex to Byte in Python, then you can do one of the following:
Read More
How to get Python logger to Print to std out
September 7, 2022
If you use Python’s logger as follows: import logging logger = logging.
Read More
How to append to an Array in Elasticsearch using elasticsearch-py
September 4, 2022
If you are using the Official ElasticSearch Python library (Docs), and you want to create an index:
Read More
How to Copy Text to the Clipboard in Python
September 3, 2022
If you need to Copy Text to the Clipboard using your Python application code, then you can do the following:
Read More
How to Read a PDF file in Python
September 2, 2022
If you need to read a PDF (Portable Document Format) file in your Python code, then you can do the following:
Read More
How to Convert HEX to RBG in Python
September 1, 2022
If you need to convert HEX (Hexadecimal) to RGB (Red-Green-Blue) in your Python code, then you can do the following:
Read More
How to Refer to a Null Object in Python
August 31, 2022
If you need to refer to a Null Object in your Python code, then you can do the following.
Read More
How to Convert Bytearray to String in Python
August 30, 2022
If you need to convert a Bytearray to a String in Python, then you can do the following:
Read More
How to get the Hostname in Python
August 29, 2022
If you need to get the Hostname in your Python application, then you can do the following:
Read More
How to get the IP Address in Python
August 28, 2022
If you need to get the IP Address in your Python application, then you can do the following:
Read More
How to use SSH in your Python application
August 27, 2022
If you need to make an SSH connection and issues commands over SSH using your Python application, then you can do the following:
Read More
How to Pause a Program in Python
August 26, 2022
If you need to pause the execution of your Python program, then you can do the following:
Read More
How to Convert String to Double in Python
August 25, 2022
If you need to convert a String to a Double in your Python code:
Read More
How to a Run Bash Command in Python
August 24, 2022
If you need to run a bash command in your Python code, then you can do the following:
Read More
How to List all Files/Folders/Directories in Python
August 20, 2022
If you need to list all Files, Folders, or Directories in Python code, then you can use the listdirs method from the os package.
Read More
How to Read a File in Python
August 19, 2022
If you need to read a file in Python, then you can use the open() built-in function to help you.
Read More
How to Drop Columns in Pandas Only If Exists
August 18, 2022
If you have a Pandas DataFrame, and want to only drop columns if they exist, then you can do the following:
Read More
How to Join Multiple MySQL Tables in Python
August 9, 2022
First, you will need the mysql.connector. If you are unsure of how to get this setup, refer to How to Install MySQL Driver in Python .
Read More
How to Limit a MySQL Query in Python
August 8, 2022
First, you will need the mysql.connector. If you are unsure of how to get this setup, refer to How to Install MySQL Driver in Python .
Read More
How to Update a MySQL Table in Python
August 7, 2022
First, you will need the mysql.connector. If you are unsure of how to get this setup, refer to How to Install MySQL Driver in Python .
Read More
How to Drop a MySQL Table in Python
August 6, 2022
First, you will need the mysql.connector. If you are unsure of how to get this setup, refer to How to Install MySQL Driver in Python .
Read More
How to Delete MySQL Records in Python
August 5, 2022
First, you will need the mysql.connector. If you are unsure of how to get this setup, refer to How to Install MySQL Driver in Python .
Read More
How to ORDER BY a MySQL Query in Python
August 4, 2022
First, you will need the mysql.connector. If you are unsure of how to get this setup, refer to How to Install MySQL Driver in Python .
Read More
How to Filter WHERE MySQL Queries in Python
August 3, 2022
First, you will need the mysql.connector. If you are unsure of how to get this setup, refer to How to Install MySQL Driver in Python .
Read More
How to Select From MySQL in Python
August 2, 2022
First, you will need the mysql.connector. If you are unsure of how to get this setup, refer to How to Install MySQL Driver in Python .
Read More
How to Insert into a MySQL Table in Python
August 1, 2022
If you need to insert data into a MySQL table using Python, then look no further.
Read More
How to Create a Primary Key for a MySQL Database in Python
July 31, 2022
You can create a Primary Key for your MySQL database in Python as follows.
Read More
How to Create a MySQL Table in Python
July 30, 2022
If you need to create a table in a MySQL database using Python, then you can do the following.
Read More
How to Create a MySQL Database in Python
July 29, 2022
In order to create a MySQL database in Python, you first need to initiate a connection using the mysql.
Read More
How to Install MySQL Driver in Python
July 28, 2022
To begin using MySQL in Python, you need to do the following:
Read More
What are the multiples of 3 from 1 to 1000
July 21, 2022
If you need to calculate the multiples of 3, starting from 1 up until 1000, then you can use the following code:
Read More
How to Disable Warning with Python Pandas
June 30, 2022
How can python pandas disable warnings? If you need to disable warnings with Pandas on Python, then you can use the warnings module and ignore the filter as follows:
Read More
How to Get all Caps Alphabet as List in Python
June 29, 2022
If we take the following list: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] How do we extract only the UpperCase letters of a given word?
Read More
How to create an AWS Lambda in Terraform
June 27, 2022
Step 1 – Lambda Code in Python The following code expects a python file with the contents as follows in a file called python/script1.
Read More
How to Generate Random Strings with Dash in-between in Python
June 18, 2022
If you need to generate a random string that looks something like this: VUNBXJ-230411, then you can use the following random generator:
Read More
How to create a Countdown Timer in Python
June 5, 2022
If you need to count down a specific amount of time, say for example, when a token is set to expire, then a countdown timer will be useful.
Read More
How to Print to stdout in Flask using Python
April 21, 2022
If you are trying to print() to the console/stdout in your Flask app, but nothing is happening, then you just need to flush your prints, as follows:
Read More
How to Dockerize a Flask App
April 14, 2022
If you have a Flask app that you would like packaged in a Docker container, then you can do the following.
Read More
How to Generate a Random String in Python
March 30, 2022
Python gives the ability to generate random strings out of the box, by using a combination of the string and random modules.
Read More
Determining Integer Depth in Python
March 20, 2022
The challenge The depth of an integer n is defined to be how many multiples of n it is necessary to compute before all 10 digits have appeared at least once in some multiple.
Read More
How to Reverse a singly-linked list in Python
March 19, 2022
The challenge Implement a function reverse_list that takes a singly-linked list of nodes and returns a matching list in the reverse order.
Read More
Calculating Simple Time Difference in Python
March 18, 2022
The challenge In this challenge, you will be given a series of times at which an alarm goes off.
Read More
Calculating Odd/Even number of divisors in Python
March 17, 2022
The challenge Given an integer n return "odd" if the number of its divisors is odd.
Read More
Calculate possibilities of throwing a coin N times in Python
March 16, 2022
The challenge In this challenge, you will be given an integer n, which is the number of times that is thrown a coin.
Read More
How to Convert Integer to Whitespace format in Python
March 15, 2022
The challenge Hereinafter, [space] refers to " ", [tab] refers to "\t", and [LF] refers to "\n" for illustrative purposes.
Read More
How to Perform Frog Jumping in Python
March 14, 2022
The challenge You have an array of integers and have a frog at the first position
Read More
How to Calculate the area of a regular N sides polygon inside a circle of radius R in Python
March 13, 2022
The challenge Write the following function: def area_of_polygon_inside_circle(circle_radius, number_of_sides): It should calculate the area of a regular polygon of numberOfSides, number-of-sides, or number_of_sides sides inside a circle of radius circleRadius, circle-radius, or circle_radius which passes through all the vertices of the polygon (such a circle is called circumscribed circle or circumcircle).
Read More
How to create an Image Host Filename Generator in Python
March 12, 2022
The challenge You are developing an image hosting website. You have to create a function for generating random and unique image filenames.
Read More
How to Find the Missing Alphabets in Python
March 11, 2022
The challenge Task Given string s, which contains only letters from a to z in lowercase.
Read More
How to Find the Longest Substring in Alphabetical Order in Python
March 8, 2022
The challenge Find the longest substring in alphabetical order. Example:
Read More
How to Binary to Text (ASCII) Conversion in Python
March 1, 2022
The challenge Write a function that takes in a binary string and returns the equivalent decoded text (the text is ASCII encoded).
Read More
How to Find the Row of the Odd Triangle in Python
February 28, 2022
The challenge Given a triangle of consecutive odd numbers: 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 .
Read More
Solving Number Zoo Patrol in Python
February 27, 2022
The challenge Write a function that takes a shuffled list of unique numbers from 1 to n with one element missing (which can be any number including n).
Read More
How to Round up to the Next Multiple of 5 in Python
February 16, 2022
The challenge Given an integer as input, can you round it to the next (meaning, “higher”) multiple of 5?
Read More
How to satisfy Wilson Primes in Python
February 14, 2022
The challenge Wilson primes satisfy the following condition. Let P represent a prime number.
Read More
Writing a Sleigh Authentication in Python
February 12, 2022
The challenge Christmas is coming and many people dreamed of having a ride with Santa’s sleigh.
Read More
Solving for Multiple of Index in Python
February 11, 2022
The challenge Return a new array consisting of elements which are multiple of their own index in input array (length > 1).
Read More
How to Find an item’s Alphabet Position in Python
February 10, 2022
The challenge When provided with a letter, return its position in the alphabet.
Read More
How to write a Lazy Repeater Helper in Python
February 3, 2022
The challenge The make_looper() function takes a string (of non-zero length) as an argument.
Read More
How to write a String Case Conversion Helper in Python
February 2, 2022
The challenge In this challenge, you will make a function that converts between camelCase, snake_case, and kebab-case.
Read More
How to create Interleaving Arrays in Python
February 1, 2022
The challenge Create a function, that accepts an arbitrary number of arrays and returns a single array generated by alternately appending elements from the passed-in arguments.
Read More
How to Find the Largest product in a Series in Python
January 31, 2022
The challenge Complete the greatestProduct method so that it’ll find the greatest product of five consecutive digits in the given string of digits.
Read More
How to Calculate the Least Common Multiple in Python
January 30, 2022
The challenge Write a function that calculates the least common multiple of its arguments; each argument is assumed to be a non-negative integer.
Read More
How to Solve Caesar Cipher Helper in Python
January 29, 2022
The challenge Write a class that, when given a string, will return an uppercase string with each letter shifted forward in the alphabet by however many spots the cipher was initialized to.
Read More
How to Write Out Numbers in Python
January 28, 2022
The challenge Create a function that transforms any positive number to a string representing the number in words.
Read More
How to do Base64 Encoding in Python
January 27, 2022
The challenge Create a function that converts the value of the String to and from Base64 using the ASCII character set.
Read More
How to Find the Unique String in Python
January 20, 2022
The challenge There is an array of strings. All strings contain similar letters except one.
Read More
How to convert a PascalCase string into snake_case in Python
January 19, 2022
The challenge Complete the function/method so that it takes a PascalCase string and returns the string in snake_case notation.
Read More
How to Convert a Hex String to RGB in Python
January 18, 2022
The challenge When working with color values it can sometimes be useful to extract the individual red, green, and blue (RGB) component values for a color.
Read More
How to Create a Hashtag Generator in Python
January 17, 2022
The challenge Write a hashtag generator function that takes a string and returns a #HashCodeString of it.
Read More
How to Move Zeros to the End in Python
January 16, 2022
The challenge Write an algorithm that takes an array and moves all of the zeros to the end, preserving the order of the other elements.
Read More
Regex for Gregorian Date Validation in Python
January 15, 2022
The challenge Write a regular expression that validates the gregorian date in the format “DD.
Read More
How to Create Your Own Python Split Function
January 14, 2022
The challenge Write your own implementation of the built-in split function in Python.
Read More
How to create a Domain Name Validator in Python
January 13, 2022
The challenge Create a domain name validator mostly compliant with RFC 1035, RFC 1123, and RFC 2181
Read More
How to write a validDate Regex in Python
January 11, 2022
The challenge Your task is to write a regular expression (regex) that will match a string only if it contains at least one valid date, in the format [mm-dd] (that is, a two-digit month, followed by a dash, followed by a two-digit date, surrounded by square brackets).
Read More
How to Validate Passwords with Regex in Python
January 10, 2022
The challenge You need to write regex that will validate a password to make sure it meets the following criteria:
Read More
How to Count the Characters in Python
January 5, 2022
The challenge The goal of this challenge is to write a function that takes two inputs: a string and a character.
Read More
How to create a Nickname Generator in Python
December 25, 2021
The challenge Write a nickname generator function, nicknameGenerator that takes a string name as an argument and returns the first 3 or 4 letters as a nickname.
Read More
How to Check for Factor in Python
December 14, 2021
The challenge This function should test if the factor is a factor of base.
Read More
How to Check if String is a Palindrome in Python
October 23, 2021
The challenge Write a function that checks if a given string (case insensitive) is a palindrome.
Read More
Find the Maximum Length Difference between Lists/Arrays in Python
October 14, 2021
The challenge You are given two arrays a1 and a2 of strings.
Read More
Largest Number Groupings in String in Python
October 12, 2021
The challenge You are be given a string that has lowercase letters and numbers.
Read More
How to Sort a List of Numbers in Python
October 10, 2021
The challenge Finish the solution so that it sorts the passed-in array/list of numbers.
Read More
Ordered Count of Characters in Python
September 14, 2021
The challenge Count the number of occurrences of each character and return it as a list of tuples in order of appearance.
Read More
Largest Pair Sum in Array in Python
September 7, 2021
The challenge Given a sequence of numbers, find the largest pair sum in the sequence.
Read More
Alphabet Symmetry in Python
September 6, 2021
The challenge Consider the word "abode". We can see that the letter a is in position 1 and b is in position 2.
Read More
Sum of Odd Cubed Numbers in Python
September 4, 2021
The challenge Find the sum of the odd numbers within an array, after cubing the initial integers.
Read More
Halving Sum in Python
September 3, 2021
The challenge Given a positive integer n, calculate the following sum:
Read More
Convert a LinkedList to a String in Python
September 2, 2021
The challenge Preloaded for you is a class, struct, or derived data type Node (depending on the language) used to construct linked lists in this challenge:
Read More
Most Digits from List in Python
September 1, 2021
The challenge Find the number with the most digits. If two numbers in the argument array have the same number of digits, return the first one in the array.
Read More
Check if all Values in Array are Smaller in Python
August 31, 2021
The challenge You will be given an array and a limit value.
Read More
Maximum Product from List of Integers in Python
August 30, 2021
The challenge Given an array of integers, Find the maximum product obtained from multiplying 2 adjacent numbers in the array.
Read More
Sum of Array Singles in Python
August 29, 2021
The challenge You are given an array of numbers in which two numbers occur once and the rest occur only twice.
Read More
Flatten and Sort an Array in Python
August 28, 2021
The challenge Given a two-dimensional array of integers, return the flattened version of the array with all the integers in the sorted (ascending) order.
Read More
Playing the Alphabet War in Python
August 27, 2021
The challenge Introduction There is a war and nobody knows – the alphabet war!
Read More
Sum of numbers from 0 to N in Python
August 26, 2021
The challenge We want to generate a function that computes the series starting from 0 and ending until the given number.
Read More
Sorted? yes? no? how? ..in Python
August 25, 2021
The challenge Complete the method which accepts an array of integers, and returns one of the following:
Read More
How to Fix String Casing in Python
August 24, 2021
The challenge You will be given a string that may have mixed uppercase and lowercase letters and your task is to convert that string to either lowercase only or uppercase only based on:
Read More
How to Remove Duplicate Words from a String in Python
August 23, 2021
The challenge Remove all duplicate words from a string, leaving only single (first) words entries.
Read More
How to Validate a Regex PIN Code in Python
August 22, 2021
The challenge ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but exactly 4 digits or exactly 6 digits.
Read More
Combine strings and remove duplicates in Python
August 21, 2021
The challenge Take 2 strings s1 and s2 including only letters from ato z.
Read More
Return Short Long Short in Python
August 17, 2021
The challenge Given 2 strings, a and b, return a string of the form short+long+short, with the shorter string on the outside and the longer string on the inside.
Read More
Hello, Name or World in Python
August 16, 2021
The challenge Define a method hello that returns “Hello, Name!” to a given name, or says Hello, World!
Read More
Add Length to Strings in Python
August 15, 2021
The challenge What if we need the length of the words separated by a space to be added at the end of that same word and have it returned as an array?
Read More
How to Reversing Words in a String in Python
August 14, 2021
The challenge Write a function that reverses the words in a given string.
Read More
How to Remove Duplicates from List in Python
August 13, 2021
The challenge Define a function that removes duplicates from an array of numbers and returns it as a result.
Read More
How to Format Dollars and Cents in Python
August 12, 2021
The challenge The company you work for has just been awarded a contract to build a payment gateway.
Read More
Return `5` without any numbers in Python
August 11, 2021
The challenge Write a function that always returns 5 Sounds easy right?
Read More
How to Generate Range of Integers in Python
August 10, 2021
The challenge Implement a function named generateRange(min, max, step), which takes three arguments and generates a range of integers from min to max, with the step.
Read More
How to Calculate Powers of 2 in Python
August 8, 2021
The challenge Complete the function that takes a non-negative integer n as input, and returns a list of all the powers of 2 with the exponent ranging from 0 to n (inclusive).
Read More
How to Get Planet Name By ID in Python
August 7, 2021
The challenge Create a function that takes in an id and returns the planet name.
Read More
How to Make a Directory if Not Exists in Python
August 6, 2021
If you want to create a directory in Python, but only if it doesn’t exist, you have the following option.
Read More
Square(n) Sum in Python
August 5, 2021
The challenge Complete the square sum function so that it squares each number passed into it and then sums the results together.
Read More
How to Fill an Array in Python
August 4, 2021
The challenge We want an array, but not just any old array, an array with contents!
Read More
Retrieve records from MSSQLServer in Python
August 2, 2021
The below Python code will create a connection to a MSSQLServer instance, and retrieve data from it back into a variable called tblResults.
Read More
How to Remove Trailing Zeroes in Python
August 1, 2021
The challenge Numbers ending with zeros are boring. They might be fun in your world, but not here.
Read More
How to use Profilers in Python
July 31, 2021
When you have performance problems in your Python application, you can use a Profiler to help you.
Read More
If you can’t Sleep, just count Sheep in Python
July 30, 2021
The challenge Given a non-negative integer, 3 for example, return a string with a murmur: "1 sheep.
Read More
Key-Value CLI Arguments in Python
July 29, 2021
If you have a CommandLine application (CLI) written in Python, you have a number of ways that you can take arguments from the user.
Read More
How to use a Translation Table to Replace Characters in Python
July 28, 2021
Python provides the ability to create Translation Tables. our_text = "This is an example of some text" translation_table = str.
Read More
How to Calculate the Sum of all Numbers in a String in Python
July 27, 2021
Let’s take the following string: numbers = "this 1 2 3 4 5 is not a 8 9 10" How can we sum up all the numbers in this string?
Read More
How to Find all Permutations of a String in Python
July 26, 2021
Python comes with a very useful module called itertools, which allows us to calculate permutations directly.
Read More
How to Reverse Words or Sentences in Python
July 24, 2021
Let’s take the following sentence: words = "These are some words" We can use slices to reverse the order of the string:
Read More
Complete Guide: How to Base64 Encode a String in Python | Python Base64 Encoding Explained
July 21, 2021
How to Base64 Encode a String in Python: A Comprehensive Guide Welcome to our comprehensive guide on how to python base64 encode a string in Python.
Read More
How to Get 10 Random Numbers in Python
July 20, 2021
The random module allows you to generate choices. import random print(random.
Read More
Get the Middle Character in Python
July 19, 2021
The challenge Return the middle character of the word. If the word’s length is odd, return the middle character.
Read More
Convert String to Datetime in Python
July 18, 2021
If you have a string and want to create a Datetime object out of it in Python, then you can use the Datetime Parse Time method, as follows:
Read More
Multiprocessing Pools in Python
July 16, 2021
Python ships with a multiprocessing module that allows your code to run functions in parallel by offloading calls to available processors.
Read More
How to Double Characters in Python
July 15, 2021
The challenge Given a string, you have to return a string in which each character (case-sensitive) is repeated once.
Read More
How to Reverse Words in Python
July 14, 2021
The challenge Complete the function that accepts a string parameter, and reverses each word in the string.
Read More
How to Count by X in Python
July 13, 2021
The challenge Create a function with two arguments that will return an array of the first (n) multiples of (x).
Read More
Calculate the Sum of Pairs in Python
July 12, 2021
The challenge Given a list of integers and a single sum value, return the first two values (parse from the left please) in order of appearance that add up to form the sum.
Read More
How to break a list into multiple lists (with maximum size) in Python
July 11, 2021
If you have a large list and want to create smaller lists of it, with a maximum amount of elements, then:
Read More
Get all dates between two dates inclusive in Python
July 10, 2021
If you want to print out a list of all dates between 2 dates (a date range), then you can use the following script:
Read More
How to Append a Python Dictionary to a Pandas DataFrame
July 9, 2021
If you want to append a Python dictionary to a Pandas DataFrame, you can do this:
Read More
Get Secret from AWS Secrets Manager in Python
July 8, 2021
You can store secrets in AWS Secret Manager and reference their ARN in AWS Systems Secret Manager.
Read More
How to do Binary Addition in Python
July 7, 2021
The challenge Implement a function that adds two numbers together and returns their sum in binary.
Read More
How to Auto-Adjust Excel column widths with pandas.ExcelWriter
July 6, 2021
You have successfully written your pandas Dataframe to an Excel file, but when you open it, all the columns are squashed up against each other.
Read More
How to Sort the Odd in Python
July 5, 2021
The challenge You will be given an array of numbers. You have to sort the odd numbers in ascending order while leaving the even numbers at their original positions.
Read More
Calculate the Sum of the two lowest positive integers in Python
July 4, 2021
The challenge Create a function that returns the sum of the two lowest positive numbers given an array of minimum 4 positive integers.
Read More
Unique In Order in Python
July 3, 2021
The challenge Implement the function unique_in_order which takes as argument a sequence and returns a list of items without any elements with the same value next to each other and preserving the original order of elements.
Read More
How to Replace Characters with Alphabet Positions in Python
June 30, 2021
The challenge Given a string, replace every letter with its position in the alphabet.
Read More
Returning Highest and Lowest in Python
June 29, 2021
The challenge You are given a string of space-separated numbers and have to return the highest and lowest number.
Read More
How to Subtract Arrays in Python
June 28, 2021
The challenge Implement a difference function, which subtracts one list from another and returns the result.
Read More
How to Solve Pascal’s Triangle in Python
June 22, 2021
The challenge Given an integer numRows, return the first numRows of Pascal’s triangle.
Read More
How to Sum The Strings in Python
June 14, 2021
The challenge Create a function that takes 2 nonnegative integers in form of a string as an input, and outputs the sum (also as a string):
Read More
Playing with passphrases in Python
June 10, 2021
The challenge Everyone knows passphrases. One can choose passphrases from poems, songs, movies names and so on but frequently they can be guessed due to common cultural references.
Read More
Find the Max Area of an Island in Python
June 4, 2021
The challenge You are given an m x n binary matrix grid.
Read More
A Simplistic TCP Finite State Machine (FSM) in Python
June 2, 2021
The challenge Automatons, or Finite State Machines (FSM), are extremely useful to programmers when it comes to software design.
Read More
How to Build a Square in Python
May 31, 2021
The challenge I will give you an integer. Give me back a shape that is as long and wide as the integer.
Read More
Check if String EndsWith in Python
May 30, 2021
The challenge Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Read More
How to LowerCase a String in Python
May 28, 2021
Python comes with a built-in method on all String types, by calling lower() on a String, you can immediately lower the case of that String.
Read More
Number to Binary Conversion in Python
May 26, 2021
If you have a decimal number, and want to get it’s binary value, you can use the built-in bin method.
Read More
Counting Binary Gaps with Python
May 25, 2021
The challenge A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N.
Read More
How to Convert an Int to a List of Ints in Python
April 16, 2021
The challenge Given a non-negative integer, return an array / a list of the individual digits in order.
Read More
How to Create a Circular List in Python
April 14, 2021
The challenge Create a Circular List A circular list is of finite size, but can infititely be asked for its previous and next elements.
Read More
Who is going to pay for the wall? in Python
October 2, 2020
The challenge Don Drumphet lives in a nice neighborhood, but one of his neighbors has started to let his house go.
Read More
Find the missing element between two arrays in Python
September 29, 2020
The challenge Given two integer arrays where the second array is a shuffled duplicate of the first array with one element missing, find the missing element.
Read More
Remove an Exclamation Mark from the End of String using Python
September 9, 2020
The challenge Remove a exclamation mark from the end of string.
Read More
Compare within Margin using Python
September 7, 2020
The challenge Create a function close_compare that accepts 3 parameters: a, b, and an optional margin.
Read More
Remove the time challenge in Python
September 5, 2020
The challenge You’re re-designing a blog and the blog’s posts have the following format for showing the date and time a post was made:
Read More
Check if List contains Item in Python
September 2, 2020
The challenge Create a method that accepts a list and an item, and returns true if the item belongs to the list, otherwise false.
Read More
How to Remove Vowels with Python
August 31, 2020
The challenge Create a function called shortcut to remove all the lowercase vowels in a given string.
Read More
How to Sort a List in Python
August 29, 2020
In this tutorial, you will learn how to sort a list in Python, by following the below three steps:
Read More
How to divide a number in Python
August 27, 2020
The challenge Your task is to create functionisDivideBy (or is_divide_by) to check if an integer number is divisible by each out of two arguments.
Read More
How many times to Kaprekar’s constant using Python
August 24, 2020
Introduction 6174 is known as Kaprekar’s constant after the Indian mathematician D.
Read More
How to check if a String is a Number in Python
August 23, 2020
The challenge Given a string s, write a method (function) that will return true if its a valid single integer or floating number or false if its not.
Read More
How to Write a Custom Comparator in Python
August 22, 2020
Generally, you want to use the built-in sorted() function which takes a custom comparator as its parameter.
Read More
How to Sort an Integer in Python
August 20, 2020
Let’s say that you have an integer with value of 9271 and you want to sort it either ascending(1279) or descending(9721).
Read More
How to Copy a File in Python
August 18, 2020
In this tutorial, you will learn how to copy a file using Python from a directory to another directory, or if you’re on Windows, then from a Folder to another Folder.
Read More
Conway’s Game of Life – Unlimited Edition – in Python
August 17, 2020
What is this? Conways’s Game Of Life is a Cellular Automation Method created by John Conway.
Read More
Most frequently used words in a text with Python
August 16, 2020
The challenge Write a function that, given a string of text (possibly with punctuation and line-breaks), returns an array of the top-3 most occurring words, in descending order of the number of occurrences.
Read More
Sort Binary Tree by Levels using Python
August 13, 2020
The challenge You are given a binary tree: class Node: def __init__(self, L, R, n): self.
Read More
How to Split a String with Python
August 12, 2020
Splitting a string in Python is really easy. You simply take a string and apply the split() method.
Read More
Converting to PigLatin with Python
August 9, 2020
The challenge Move the first letter of each word to the end of it, then add “ay” to the end of the word.
Read More
Multiples of 3 and 5 with Python
August 5, 2020
The challenge This multiples of 3 and multiples of 5 challenge is a variation of the common FizzBuzz question.
Read More
Solving the “Catching Car Mileage Numbers” Challenge using Python
August 4, 2020
The challenge "7777…8?!??!", exclaimed Bob, "I missed it again! Argh!" Every time there's an interesting number coming up, he notices and then promptly forgets.
Read More
Counting smiley faces with Python
August 3, 2020
The challenge Given an array (arr) as an argument complete the function countSmileys that should return the total number of smiling faces.
Read More
How to Convert Numeric Words into Numbers using Python
July 31, 2020
Challenge Using Python, we want to convert words into numbers. In this challenge, we will explore how to convert a string into an integer.
Read More
Solve The Triangle of Odd Numbers using Python
July 30, 2020
The challenge Given the triangle of consecutive odd numbers: 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 .
Read More
“Who likes it” code Challenge in Python
July 29, 2020
The Challenge You probably know the “like” system from Facebook and other pages.
Read More
Python 4 New Features Planned
July 28, 2020
It took the Python community a long time to move from Python 2 to Python 3.
Read More
Custom RGB To Hex Conversion with Python
July 27, 2020
The challenge The rgb function is incomplete. Complete it so that passing in RGB decimal values will result in a hexadecimal representation being returned.
Read More
How to write a Chain Adding Function in Python
July 24, 2020
The challenge We want to create a function that will add numbers together when called in succession.
Read More
Get the next biggest number with the same digits using Python
July 23, 2020
The challenge Create a function that takes a positive integer and returns the next bigger number that can be formed by rearranging its digits.
Read More
Solving Tribonacci Sequence with Python
July 22, 2020
The challenge As the name may already reveal, it works basically like a Fibonacci, but summing the last 3 (instead of 2) numbers of the sequence to generate the next.
Read More
The Casino Chips Problem Solved with Python
July 21, 2020
The challenge You are given three piles of casino chips: white, green and black chips:
Read More
Check if Isogram using Python
July 20, 2020
The challenge An isogram is a word that has no repeating letters, consecutive or non-consecutive.
Read More
Find the Longest Common Prefix using Python
July 19, 2020
The challenge Write a function to find the longest common prefix string amongst an array of strings.
Read More
Count and Say with Python
July 18, 2020
The challenge he count-and-say sequence is the sequence of integers with the first five terms as following:
Read More
The Plus One problem solved with Python
July 17, 2020
The challenge Given a non-empty array of digits representing a non-negative integer, increment one to the integer.
Read More
Solving the Single Number problem in Python
July 16, 2020
The challenge Given a non-empty array of integers, every element appears twice except for one.
Read More
Rotate a Matrix List in Python
July 15, 2020
The challenge You are given an n x n 2D matrix representing an image.
Read More
Find the Intersection of Two Arrays in Python
July 13, 2020
The challenge Given two arrays, write a function to compute their intersection.
Read More
Rotate an Array K Times in Python
July 12, 2020
The challenge Given an array, rotate the array to the right by k steps, where k is non-negative.
Read More
Python Splices reimplemented in Java
July 10, 2020
Python has a fantastic feature called slices. It allows you to work with a list, set or string by it’s index items.
Read More
Solving Two Sum in Python
July 9, 2020
The challenge Given an array of integers, return indices of the two numbers such that they add up to a specific target.
Read More
Get the Next Small Integer in Python
July 8, 2020
The challenge Write a function: def solution(A) that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A.
Read More
Find All Numbers Disappeared in an Array using Python
June 26, 2020
The challenge Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.
Read More
HashMaps (aka: Dictionaries) in Python
June 19, 2020
Introduction Java has a built-in called HashMap. It allows you to store and very quickly retrieve key value pairs.
Read More
Get The Shortest Path in Binary Matrix using Python
June 15, 2020
The challenge In an N by N square grid, each cell is either empty (0) or blocked (1).
Read More
Palindrome Partitioning in Python
June 14, 2020
The problem Given a string s, partition s such that every substring of the partition is a palindrome.
Read More
Best Time to Buy and Sell Stock with Python
June 12, 2020
The problem Say you have an array prices for which the ith element is the price of a given stock on day i.
Read More
Self Dividing Numbers using Python
May 28, 2020
Introduction A self-dividing number is a number that is divisible by every digit it contains.
Read More
RuntimeError: thread.__init__() not called (Python)
May 27, 2020
Today I got a really dumb error from Python. RuntimeError: thread.
Read More
How to get the UTC Timestamp in Python
May 7, 2020
All dates in your server applications should be stored in the UTC timezone.
Read More
How to make an HTTP Request in AWS Lambda using Python
April 28, 2020
The requests module for Python is very useful in helping simplify HTTP/s requests from Python, but how would you use it in an AWS Lambda script?
Read More
Get the Maximum Length of a Concatenated String with Unique Characters in Python
April 18, 2020
The problem Given an array of strings arr. String s is a concatenation of a sub-sequence of arr which have unique characters.
Read More
How to get the last element of a list in Python
April 11, 2020
Let’s say that you have a Python list with the following 5 foods:
Read More
How to embed a web server in your Python3 app
April 10, 2020
This is not the first time that I created a Python3 application that spat out some output and required access to it via an HTTP server.
Read More
How to duplicate zeros in place using Python
April 8, 2020
Given a fixed length array arr of integers, duplicate each occurrence of zero, shifting the remaining elements to the right.
Read More
A Quick Introduction to Asyncio in Python3
April 7, 2020
Python has never been the best at doing multiple things at the same time.
Read More
How to Reorder Data in Log Files using Python
April 2, 2020
Let’s say that you have an array or a list, or logs.
Read More
How to implement a Queue using Stacks in Python
March 30, 2020
A common programming interview question, and for a change, one that you will actually be able to use in the job, is that of implementing a Queue by means of using Stacks in Python.
Read More
Find positions of largest groups of characters in a String with Python
March 29, 2020
The question Take a string S of lowercase letters. These letters form consecutive groupings of like characters.
Read More
How to Measure Execution Time in Google Colab
March 26, 2020
Google Colab is a fantastic environment to write Python code using Jupyter Notebooks, hosted for free by Google.
Read More
How to fake a User Agent in Python
March 25, 2020
A User-Agent is a bunch of text that is sent with every HTTP and HTTPS request.
Read More
Read the bottom n lines of a file in Python
March 22, 2020
Using Operating System Commands in Python Use the Linux/Mac tail command to provide the data:
Read More
How to make a Python script Pip-installable
March 19, 2020
As Python developers, we’ve all used pip to install applications, but speaking to other Python developers, it’s not always clear how to make your own application/script pip-installable.
Read More
How to send emails using Python and AWS SES SMTP
March 17, 2020
Sending emails using Python and AWS’ SES service is really easy.
Read More
Read the top n lines of a file in Python
March 14, 2020
Sometimes you may need to read the top n lines of a file using Python.
Read More
How Fast is your Website?
March 13, 2020
I operate a bunch of different sites and have done for many years now.
Read More
Get the Amount of Days Between Two Dates in Python
March 7, 2020
Let’s say that you have two dates: "2019-01-29" "2019-06-30" How would you create a function that would return the number of days between these two dates?
Read More
How to Always run Python 3 from Bash
March 6, 2020
Given a directory that contains: | |- app.py |- requirements.txt |- .
Read More
How to tell if a year is a Leap Year in Python
March 4, 2020
Given that we are in a leap year this year (2020), it would be nice to know how to programmatically calculate this.
Read More
How to Reverse a Linked List in Python
March 3, 2020
It’s important to know about data types and one that comes up fairly regularly is that of Linked Lists.
Read More
How to package a Python app (pip) for PyPi
February 28, 2020
In this tutorial, we will create a Python application that can be installed directly from pip that will show the 10 latest blog posts from this website (the one you are reading this on!
Read More
How to find the longest Palindrome in a String using Python
February 27, 2020
This occasionally comes up during coding interviews and is actually quite a decent way to test someone’s aptitude of moving back and forth on a string to determine if and where palindromes exist.
Read More
How to get the Maximum Depth of a Binary Tree in Python
February 24, 2020
Let’s say that you have a binary tree and we needed to know it’s maximum depth.
Read More
What is Fizz Buzz?
February 23, 2020
Fizz buzz is a common programming interview question. The problem statement usually reads something like this:
Read More
How to write a Quicksort Algorithm in Python
February 21, 2020
While there are libraries available for all programming languages that offer abilities to sort list, arrays and collections, it is important to know how this is achieved.
Read More
How to Reverse a String or List using Python
February 20, 2020
Python comes with the power of slicing. Let’s try it with a String:
Read More
How to get the IP address in Python
February 19, 2020
Python exposes a socket library that allows us to perform networking tasks such as getting the IP Address as well as getting the Hostname of our system.
Read More
How to Reverse a Binary Tree in Python
February 18, 2020
Reversing a Binary Tree is a common programming interview question.
Read More
How to delete a file in Python
February 16, 2020
A quick solution in Python import os os.remove("filename.txt") The above code will delete a file in Python, it will not however delete a directory, or a directory containing files.
Read More
When to use Pip3 instead of Pip in Python
February 10, 2020
If you have multiple versions of Python installed on a system, such as both Python 2.
Read More
How to Package a Python App using Nuitka
February 7, 2020
Learn how to package a Python app in this tutorial.
Read More
When your Python code is much faster with PyPy
February 4, 2020
Python is a very powerful language, there are so many libraries available for it.
Read More
Introduction to PIP – Python Package Manager
February 2, 2020
Python comes with a fully equipped package manager called PIP – which stands for the Python Package Manager.
Read More
How to Setup and Use the Python Virtual Environment
January 28, 2020
Python is a fantastic language that continues to help so many businesses and individuals.
Read More
Multiprocessing in Python3
January 14, 2020
import multiprocessing def runner(k): print(k) processes = [] for i in range(10): p = multiprocessing.
Read More
Counting in Python using a list
September 25, 2018
So before we begin, let me just tell you that this is a pretty useless thing to do.
Read More
[Solved] Pip: There was a problem confirming the ssl certificate
February 26, 2018
If you ever get the following error when trying to install a Pip module under Python:
Read More
How to Learn Python Programming Quickly
February 22, 2018
So you want to learn to program in Python and you don’t have a lot of time?
Read More
NoSQL Pandas Dataframes
February 16, 2018
Pandas Dataframes are simply a table with some rows (McKinney, 2015) and many additional features built right in to make data scientists lives much easier.
Read More
python "AttributeError: ZipFile instance has no attribute ‘__exit__"
May 8, 2013
This is actually a very easy error to fix, eventhough off the bat it seems a lot more involved.
Read More
ImportError: No module named MySQLdb (Python)
July 23, 2012
Trying to use MySQL with Python and getting an ImportError?
Read More