Found 26504 Articles for Server Side Programming

Python Program to Recursively Linearly Search an Element in an Array

Gireesha Devara
Updated on 15-May-2023 16:39:34

2K+ Views

Linear search is the simplest method of searching for an element in an array. It is a sequential searching algorithm that starts from one end and checks every element of the array until the desired element is found. Recursion means a function that calls itself, while using a recusive function we need to use any loop to generate the iterations. The below syntax demonistrates the working of a simple recursion function. def rerecursiveFun(): Statements ... rerecursiveFun() ... rerecursiveFun Linear Search of an Element ... Read More

Python Program to Multiply two Matrices by Passing Matrix to a Function

Gireesha Devara
Updated on 15-May-2023 16:38:14

314 Views

A matrix is a two-dimensional array of many numbers arranged in rows and columns. And it is called as m X n matrix where m and n are the dimensions. In general, the multiplication of two matrices can be possible only if the number of columns in the first matrix is equal to the number of rows in the second matrix. Input Output Scenarios Assuming we have two input matrices A and B having 3X3 rows and columns. Then the resultant matrix will also have 3 rows and 3 column. [a, b, c] [j, k, l] [(a*j+b*m+c*p), (a*k+b*n+c*q), (a*l+b*o+c*r)] [d, ... Read More

Python Program To Find the Trace and Normal of a given Matrix

Gireesha Devara
Updated on 15-May-2023 16:35:50

2K+ Views

A matrix is defined as a set of numbers arranged in rows and columns. A matrix with m rows and n columns is called an m X n matrix and m and n are called its dimensions. A matrix is a two dimensional array, which is created by using lists or NumPy arrays in python. The Trace of a Matrix The trace of a matrix is defined as the sum of its diagonal elements (i.e, elements from upper left to lower right ). Calculating the Trace of a matrix can be possible only for a square matrix (i.e., the matrix ... Read More

Python Program to Multiply to Matrix Using Multi-dimensional Arrays

Gireesha Devara
Updated on 15-May-2023 16:34:12

477 Views

A matrix is a set of numbers arranged in rows and columns. A matrix with m rows and n columns is called an m X n matrix and m and n are called its dimensions. A matrix is a two dimensional array, which is created by using lists or NumPy arrays in python. In general, Matrix multiplication can be done by multiplying the rows of the first matrix by the column of the second matrix. Here, the number of columns of the first matrix should be equal to the number of rows of the second matrix. Input Output Scenarios Assuming ... Read More

Python Program to Add Two Matrix Using Multi-dimensional Array

Gireesha Devara
Updated on 15-May-2023 16:32:53

1K+ Views

A matrix is a two-dimensional array of many numbers arranged in rows and columns. The addition of two matrices is a process of adding corresponding elements of two matrices and placing the sum in corresponding position of the resultant matrix. And this can be possible, only if both the matrices have an equal number of rows and columns. In Python multidimensional arrays are created by using lists or NumPy arrays. The list data structure can accept lists as elements so that we can easily create matrice. Also, the Numpy module provides numerous methods to work with multidimensional arrays. ... Read More

Python Program to Interchange the Diagonals of a matrix using predefined methods

Gireesha Devara
Updated on 15-May-2023 16:31:21

316 Views

The diagonals are nothing but crosswise elements of a matrix. A square matrix has two diagonals. One is the Primary diagonal - located from the top left corner to the bottom right corner of a square matrix. And the second one is the Secondary diagonal - located from the top right to the bottom left corner. Interchange the diagonals is nothing but changing the primary and secondary diagonal elements of a matrix. See the below scenarios to understand it briefly Input Output Scenarios Assume we have a square matrix. And output matrix will be the resultant matrix ... Read More

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

Gireesha Devara
Updated on 15-May-2023 16:29:12

274 Views

A matrix is a two-dimensional array of many numbers arranged in rows and columns form. Python does not have any data type to represent a matrix, but we can use a nested list or NumPy array as a matrix. See the below input output scenarios to understand how to interchange the first and last column elements of a matrix. Input Output Scenarios Assume we have a 3X3 matrix represented using a list of lists. And output matrix will be the resultant matrix whose first and last column elements are interchanged. Input matrix: [1, 3, 4] [4, 5, 6] [7, ... Read More

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

Gireesha Devara
Updated on 15-May-2023 16:26:53

154 Views

A matrix is a set of numbers arranged in rows and columns format. In python, a matrix can not be created directly. Instead, we can use a nested list or NumPy array as a matrix. The interchanging of first and last row elements of a matrix is demonstrated below. Input Output Scenarios Assume we have a 3X3 matrix represented using a nested list. and output matrix will be the resultant matrix whose first and last row elements are interchanged. Input matrix: [1, 2, 3] [4, 5, 6] [7, 8, 9] Output matrix: [7, 8, 9] [4, 5, ... Read More

How do I create a constant in Python?

Gireesha Devara
Updated on 15-May-2023 16:05:28

2K+ Views

The constants and variables are used to store data values in programming. A variable generally refers to a value that can change over time. Whereas, a constant is a type of variable whose value cannot be changed during a program’s execution. There are only six built-in constants available in Python which are False, True, None, Not Implemented, Ellipsis( ...), and __debug__. Other than these constants, python does not have any built-in data type to store the constant values. Example A sample example of a constant is demonstrated below − False = 100 Output SyntaxError: cannot assign to False ... Read More

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

Manthan Ghasadiya
Updated on 12-May-2023 16:14:13

7K+ Views

In this tutorial, we will learn how to display notnull rows and columns in a Python dataframe with the help of some libraries. We will be using the Pandas library in this tutorial. A dataframe is a data structure in pandas similar to an Excel sheet or a SQL table. It is a two-dimensional labeled data structure that can hold multiple columns of potentially different types of data such as integer, float, string, etc. Pandas provides a powerful data structure, "dataframe" and other useful methods to work on huge data. Approach 1 One way to display the non-null rows and ... Read More

Advertisements