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

Guide to Basic Data Types in Python with Examples

Introduction to Python Data Types In this article, we’ll be diving into the Basic Data Types in Python. These form some of the fundamental ways you can represent data. One way to categorize these basic data types is in one of four groups: Numeric: int, float and the less frequently encountered complex Sequence: str (string), list and tuple Boolean: (True or False) Dictionary: dict(dictionary) data type, consisting of (key, value) pairs It’s important to point out that Python usually doesn’t […]

Read more

Deep Learning Models in Keras – Exploratory Data Analysis (EDA)

Introduction Deep learning is one of the most interesting and promising areas of artificial intelligence (AI) and machine learning currently. With great advances in technology and algorithms in recent years, deep learning has opened the door to a new era of AI applications. In many of these applications, deep learning algorithms performed equal to human experts and sometimes surpassed them. Python has become the go-to language for Machine Learning and many of the most popular and powerful deep learning libraries […]

Read more
1 868 869 870 871 872 901