How to Print Spaces in Python

Problem Formulation and Solution Overview This article will show various ways to print a single or multiple spaces in Python. Let’s say you have strings and would like to print them out to the terminal by placing a single or multiple spaces between them. πŸ’¬ Question: How would we write code to print spaces? We … Read more

5 Ways to Check If a Dictionary is Empty in Python

Problem Formulation and Solution Overview This article will show you how to check if a Dictionary is empty in Python. Before moving forward, let’s review what a Python Dictionary is. πŸ’‘Dictionary Overview: The Python Dictionary is a data structure that houses key:value pairs of data. This data structure does not allow duplicate keys, thus ensuring … Read more

How to Change File Permissions in Python?

Problem Formulation and Solution Overview When a new file or folder is created, it comes with its own set of default permissions. From time to time, you will need to adjust these permissions. To follow this article, download the finxter.csv file and move this file to the current working directory. What are File Permissions? File … Read more

How to Extract a Subset from a Dictionary in Python

Problem Formulation and Solution Overview This article will show you how to extract a subset from a Dictionary in Python. Our article works with a Dictionary called cars, containing 30 key:value pairs: a name and associated horsepower. πŸ’¬ Question: How would we write code to extract a subset from a Dictionary? We can accomplish this … Read more

How to Get a Random Entry from a Python Dictionary

Problem Formulation and Solution Overview This article will show you how to get a random entry from a Dictionary in Python. To make it more interesting, we have the following running scenario: πŸ‘¨β€πŸ« The Plot: Mr. Sinclair, an 8th great Science Teacher, is giving his students a quiz on the first 25 Periodic Table elements. … Read more

How to Apply a Function to a Python List

Problem Formulation and Solution Overview This article will show you how to apply a function to a List in Python. To make it more interesting, we have the following running scenario: As a Python assignment, you have been given a List of Integers and asked to apply a function to each List element in various … Read more

How to Find the Most Common Element in a NumPy Array

Problem Formulation and Solution Overview This article will show you how to find the most common element in a NumPy Array. To make it more interesting, we have the following running scenario: Carrie heard that Creative Prints is hiring a Python coder. They require the interviewee to answer several coding questions: one is to provide … Read more

Python – Finding the Most Common Element in a Column

Problem Formulation and Solution Overview This article will show you how to find the most common element in a Pandas Column. To make it more interesting, we have the following running scenario: You have been provided with a downloadable CSV file containing crime statistics for the San Diego area, including their respective NCIC Crime Codes. … Read more

How to Find the Most Common Element in a Python String

Problem Formulation and Solution Overview This article will show you how to find the most common element in a Python string. To make it more interesting, we have the following running scenario: Sven, a Photographer, turned Python Coder, was called for an interview at Edge IT. Sven thought the interview was going well until he … Read more