Binary Search in Python

Introduction In this article, we’ll be diving into the idea behind and Python implementation of Binary Search. Binary Search is an efficient search algorithm that works on sorted arrays. It’s often used as one of the first examples of algorithms that run in logarithmic time (O(logn)) because of its intuitive behavior, and is a fundamental algorithm in Computer Science. Binary Search – Example Binary Search works on a divide-and-conquer approach and relies on the fact that the array is sorted […]

Read more

Reading and Writing Excel (XLSX) Files in Python with the Pandas Library

Introduction Just like with all other types of files, you can use the Pandas library to read and write Excel files using Python as well. In this short tutorial, we are going to discuss how to read and write Excel files via DataFrames. In addition to simple reading and writing, we will also learn how to write multiple DataFrames into an Excel file, how to read specific rows and columns from a spreadsheet, and how to name single and multiple […]

Read more

any() and all() in Python with Examples

Introduction to any() and all() In this tutorial, we’ll be covering the any() and all() functions in Python. The any(iterable) and all(iterable) are built-in functions in Python and have been around since Python 2.5 was released. Both functions are equivalent to writing a series of or and and operators respectively between each of the elements of the passed iterable. They are both convenience functions that shorten the code by replacing boilerplate loops. Both methods short-circuit and return a value as […]

Read more

Calculating Mean, Median, and Mode in Python

Introduction When we’re trying to describe and summarize a sample of data, we probably start by finding the mean (or average), the median, and the mode of the data. These are central tendency measures and are often our first look at a dataset. In this tutorial, we’ll learn how to find or compute the mean, the median, and the mode in Python. We’ll first code a Python function for each measure followed by using Python’s statistics module to accomplish the […]

Read more

Statistical Hypothesis Analysis in Python with ANOVAs, Chi-Square, and Pearson Correlation

Introduction Python is an incredibly versatile language, useful for a wide variety of tasks in a wide range of disciplines. One such discipline is statistical analysis on datasets, and along with SPSS, Python is one of the most common tools for statistics. Python’s user-friendly and intuitive nature makes running statistical tests and implementing analytical techniques easy, especially through the use of the statsmodels library. Introducing The statsmodels Library In Python The statsmodels library is a module for Python that gives […]

Read more

Bucket Sort in Python

Introduction In this tutorial, we’ll be diving into the theory and implementation of Bucket Sort in Python. Bucket Sort is a comparison-type algorithm which assigns elements of a list we want to sort in Buckets, or Bins. The contents of these buckets are then sorted, typically with another algorithm. After sorting, the contents of the buckets are appended, forming a sorted collection. Bucket Sort can be thought of as a scatter-order-gather approach towards sorting a list, due to the fact […]

Read more

How to Write a Makefile – Automating Python Setup, Compilation, and Testing

Introduction When you want to run a project that has multiple sources, resources, etc., you need to make sure that all of the code is recompiled before the main program is compiled or run. For example, imagine our software looks something like this: main_program.source -> uses the libraries `math.source` and `draw.source` math.source -> uses the libraries `floating_point_calc.source` and `integer_calc.source` draw.source -> uses the library `opengl.source` So if we make a change in opengl.source for example, we need to recompile both […]

Read more

‘is’ vs ‘==’ in Python – Object Comparison

‘is’ vs ‘==’ in Python Python has two very similar operators for checking whether two objects are equal. These two operators are is and ==. They are usually confused with one another because with simple data types, like ints and strings (which many people start learning Python with) they seem to do the same thing: x = 5 s = “example” print(“x == 5: ” + str(x == 5)) print(“x is 5: ” + str(x is 5)) print(“s == ‘example’: […]

Read more

Managing Python Environments with direnv and pyenv

Introduction As Python developers, most of us are familiar with Virtual Environments. One of the first things we do when working on a new project is to create an environment. We commonly use virtualenv or venv exactly for that purpose. Each project we work on uses different packages and may even be compatible with only one Python version. Doing something repeatedly warrants automation. In this article, we’ll see how direnv and pyenv can help us do that. As a side […]

Read more

What’s New in Tensorflow 2.0?

Introduction If you are a Machine Learning Engineer, Data Scientist, or a hobbyist developing Machine Learning Models from time to time just for fun, then it is very likely that you are familiar with Tensorflow. Tensorflow is an open-source and a free framework developed by Google Brain Team written in Python, C++, and CUDA. It is used to develop, test, and deploy Machine Learning models. Initially, Tensoflow did not have full support for multiple platforms and programming languages, and it […]

Read more
1 877 878 879 880 881 910