## How to Calculate distance between Two Points in 3D in Python

To calculate the distance between two points in 3D in Python, use the math.dist() method. The math.dist() is a built-in Python function used to calculate the Euclidean distance between two points x and y, each given as a sequence (or iterable) of coordinates. import math a = (5, 4, 3) b = (6, 2, 4) dis = math.dist(a, … Read more

## How to Calculate Euclidean distance in Python

To calculate the euclidean distance in Python, use the math.dist() function. The math.dist() is a built-in method that returns the Euclidean distance between two points (x and y), where x and y are the coordinates of that point. Euclidean distance is the widely used technique for finding the distance between two points. This formula can … Read more

## How to Filter List in Python

To filter a list in Python, use the filter() method. The filter() is a built-in Python method that filters the list with the help of a function that tests each item in the list. If it passes the test, it will be included in the output; otherwise not. Let’s see a scenario in which we … Read more

## How to Copy Files in Python

To copy files in Python, use the shutil.copyfile() method. The shutil.copyfile() method copies the source file’s content to the destination file. The metadata of the file is not copied. Source and destination must represent a file, and destination must be writable. To work with files in Python, file handling is the prerequisite to play with the files … Read more

## How to Read CSV File in Python

To read a csv file in Python, use the csv.reader() function. The csv.reader() function reads the file, which returns an iterable reader object. The reader object is then iterated using a for loop to print the contents of each row. CSV stands for Comma Separated Values. It is a file consisting of values separated by values. … Read more

## How to Perform Matrix Multiplication in Python

Matrix multiplication is an operation in which we multiply two or more matrices. A matrix consists of m rows and n columns. Each row from matrix1 is multiplied by each column in matrix2. Program for matrix multiplication in Python mat1 = [[14, 5, 8], [3, 7, 9], [8, 9, 7]] mat2 = [[8, 6, 4, … Read more

## How to Convert File to tar.gz in Python

To convert a file to tar.gz in Python, use the gzip.open() function. The gzip.open() function opens a gzip-compressed file in binary or text mode, returning a file object. The gzip module provides the open(), compress(), and decompress() convenience functions. Program to convert file to .gz import gzip file = open(“/Users/krunallathiya/Desktop/Code/R/sample.txt”) zipped = gzip.open(“/Users/krunallathiya/Desktop/Code/R/sample.tar.gz”, “wb”) zipped.writelines(file) zipped.close() … Read more

## How to Tabulate JSON in Python

To tabulate JSON data in Python, use the pd.DataFrame() function. The pd.DataFrame() is a Pandas library function that helps us create two-dimensional, size-mutable, potentially heterogeneous tabular data in Python. JSON stands for JavaScript Object Notation. It is somewhat similar to the Python dictionary. The JSON data type is mainly used to exchange data between clients … Read more