Python Program to Add Two Matrix Using Multi-dimensional Array

Gireesha Devara
Updated on 27-Mar-2026 06:39:33

1K+ Views

A matrix is a two-dimensional array of numbers arranged in rows and columns. The addition of two matrices involves adding corresponding elements and placing the sum in the corresponding position of the resultant matrix. This operation is only possible when both matrices have equal dimensions. In Python, multidimensional arrays are created using lists or NumPy arrays. The list data structure can accept lists as elements, making it easy to create matrices. The NumPy module provides numerous methods to work efficiently with multidimensional arrays. Matrix Addition Formula For two matrices A and B, the addition follows this pattern ... Read More

Python Program to Interchange Elements of First and Last in a Matrix Across Columns

Gireesha Devara
Updated on 27-Mar-2026 06:39:08

372 Views

A matrix is a two-dimensional array of numbers arranged in rows and columns. Python doesn't have a built-in matrix data type, but we can use nested lists or NumPy arrays to represent matrices. In this tutorial, we'll learn how to interchange the first and last column elements in each row of a matrix using different approaches. Input Output Scenarios Let's understand the problem with examples. For a 3×3 matrix, we swap the first and last elements of each row ? # Example 1: Square matrix original = [ [1, 3, 4], ... Read More

Python Program to Interchange Elements of First and Last in a Matrix Across Rows

Gireesha Devara
Updated on 27-Mar-2026 06:38:41

255 Views

A matrix is a set of numbers arranged in rows and columns format. In Python, a matrix can be created using nested lists or NumPy arrays. This tutorial demonstrates how to interchange the first and last rows of a matrix. Input Output Scenarios Let's look at examples of interchanging first and last rows in different matrices ? Input matrix: [1, 2, 3] [4, 5, 6] [7, 8, 9] Output matrix: [7, 8, 9] [4, 5, 6] [1, 2, 3] For matrices with unequal row lengths ? Input matrix: ... Read More

How do I create a constant in Python?

Gireesha Devara
Updated on 27-Mar-2026 06:38:19

2K+ Views

In Python, there's no built-in data type for constants like other programming languages. However, Python follows naming conventions and provides several approaches to create constants that signal to other developers that a value shouldn't be changed. Built-in Constants in Python Python has six built-in constants: False, True, None, NotImplemented, Ellipsis (...), and __debug__. These cannot be reassigned ? # Trying to reassign a built-in constant raises SyntaxError try: False = 100 except SyntaxError as e: print(f"Error: {e}") File "", line 2 ... Read More

How to display notnull rows and columns in a Python dataframe?

Manthan Ghasadiya
Updated on 27-Mar-2026 06:37:57

7K+ Views

In this tutorial, we will learn how to display notnull rows and columns in a Python dataframe using the Pandas library. A dataframe is a two-dimensional labeled data structure that can hold multiple columns of potentially different data types such as integer, float, string, etc. Using dropna() Method The dropna() method returns a dataframe with all rows and columns containing null values removed from the original dataframe ? Syntax df.dropna() Example In this example, we create a sample dataframe with some null values and use dropna() to remove rows containing any null ... Read More

How to display most frequent value in a Pandas series?

Manthan Ghasadiya
Updated on 27-Mar-2026 06:37:32

9K+ Views

In this tutorial, we will learn how to display the most frequent value in a Pandas series. A Pandas Series is a one-dimensional labeled data structure that can hold different data types like integers, floats, and strings. The most frequent value is also known as the mode of the data. Using value_counts() Method The value_counts() method returns a Series with counts of each unique value sorted in descending order. The most frequent value appears first. Syntax counts = series.value_counts() most_frequent = counts.index[0] Example with Numbers Let's find the most frequent number in ... Read More

How to delete only one row in csv with Python?

Manthan Ghasadiya
Updated on 27-Mar-2026 06:37:07

23K+ Views

In this tutorial, we will learn to delete only one row in CSV with Python using the Pandas library. Pandas is an open-source library for data analysis that provides several functionalities to perform operations on data sets. We will use the drop() method to delete a row from any CSV file. This tutorial illustrates three different approaches to delete a row from CSV files using the same method. Syntax Here's the basic syntax to delete a row from a CSV file ? import pandas as pd # Read CSV file df = pd.read_csv("filename.csv") ... Read More

How to make Violinpot with data points in Seaborn?

Manthan Ghasadiya
Updated on 27-Mar-2026 06:36:42

499 Views

In data analysis and visualization, violin plots are powerful tools for visualizing the distribution of numeric data across different categories. Unlike box plots, violin plots show the full distribution shape by combining a box plot with a kernel density estimation. In this tutorial, we will learn how to create violin plots with data points using Seaborn. To create violin plots in Seaborn, we need to import the necessary libraries: Seaborn for plotting, Matplotlib for customization, and Pandas for data manipulation. Syntax The basic syntax for creating a violin plot with data points is − import ... Read More

How to delete only empty folders in Python?

Manthan Ghasadiya
Updated on 27-Mar-2026 06:36:17

3K+ Views

In this tutorial, we will learn how to delete only empty folders in Python. As you delete files or uninstall programs, empty folders might build up over time, but they can be challenging to locate and manually eliminate. Fortunately, Python offers a quick and effective way to delete empty directories automatically. Approach We can use the built-in os module to identify and delete empty folders using Python. Here's the basic workflow of how we can achieve this ? Use os.walk() to traverse the file system recursively, starting at a given root directory. For each directory encountered ... Read More

Which is Better to Learn Machine Learning: C++, Python, or R?

Devang Delvadiya
Updated on 27-Mar-2026 06:35:51

480 Views

Machine learning (ML) is the study of computer algorithms that learn patterns from data without explicit programming. When choosing a programming language for ML, three popular options are C++, Python, and R. Each has distinct advantages depending on your goals and experience level. What is Machine Learning? Machine Learning enables computers to identify patterns and make predictions by processing large datasets. It's widely used in healthcare, finance, e-commerce, manufacturing, and transportation. Tech giants like Google, Apple, and Microsoft rely heavily on ML to enhance user experiences and optimize operations. C++ for Machine Learning C++ is a ... Read More

Advertisements