Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
Email + Social Logins in Django - Step-by-Step Guide
Email and social logins are essential authentication methods for modern web applications. Email login requires users to provide their email address and password, while social login allows users to authenticate using their existing accounts from platforms like Google or Facebook. In this tutorial, we'll implement both authentication methods in Django using the Django-allauth package. Installation First, install the django-allauth package using pip ? pip install django-allauth Project Setup Step 1: Configure Settings Add the required configurations to your settings.py file ? # settings.py INSTALLED_APPS = [ ...
Read MorePython program to find the smallest word in a sentence
Welcome to this tutorial on writing a Python program to find the smallest word in a sentence. Whether you are a beginner or intermediate Python programmer, this guide will help you learn text manipulation using Python's built-in functions. Problem Statement Given a sentence, we need to find the word with the fewest characters. In case of a tie, we'll return the first occurring smallest word. Using min() with key Parameter The most efficient approach uses the min() function with a key parameter to compare word lengths ? def find_smallest_word(sentence): # ...
Read MorePython Program to get the subarray from an array using a specified range of indices
An array is a homogeneous data structure used to store elements of the same data type. Each element is identified by a key or index value. Python provides several ways to extract subarrays from arrays using specified index ranges. What is a Subarray? A subarray is a continuous portion of elements from an array. For example, if we have an array: numbers = [9, 3, 1, 6, 9] print("Original array:", numbers) Original array: [9, 3, 1, 6, 9] The possible subarrays include: [9, 3] [9, 3, 1] [3, ...
Read MorePython Program to push an array into another array
In programming, an array is a data structure used to store a collection of homogeneous data elements. Each element is identified by an index value. Python doesn't have a specific array data type, so we use lists as arrays. Arrays in Python Here's how we represent a list as an array ? numbers = [1, 4, 6, 5, 3] print(numbers) [1, 4, 6, 5, 3] Python indexing starts from 0, so elements are accessed using index values 0, 1, 2, 3, 4. Pushing an array into another array means inserting ...
Read MorePython Program to convert an array into a string and join elements with a specified character
An array is a data structure consisting of a collection of elements of the same data type, where each element is identified by an index. In Python, we use lists to represent arrays and can convert them to strings with custom separators. Arrays in Python Python uses the list data structure to represent arrays. Here's an example of a list representing an array − numbers = [10, 4, 11, 76, 99] print(numbers) [10, 4, 11, 76, 99] Input Output Scenarios Let's see how array elements can be joined with specified ...
Read MorePython Program To Determine If a Given Matrix is a Sparse Matrix
A matrix is a rectangular array of numbers arranged in rows and columns. A sparse matrix is one that contains significantly more zero elements than non-zero elements − typically when more than half of the elements are zero. What is a Sparse Matrix? Consider this example matrix ? [0, 0, 3, 0, 0] [0, 1, 0, 0, 6] [1, 0, 0, 9, 0] [0, 0, 2, 0, 0] This 4×5 matrix has 20 total elements but only 6 non-zero values. Since 14 out of 20 elements are zero (70%), this qualifies as a sparse ...
Read MorePython Program to Display Upper Triangular Matrix
A matrix is a two-dimensional array of numbers arranged in rows and columns. A square matrix (whose rows and columns have the same number of elements) has two diagonals. One is the primary diagonal − located from the top left corner to the bottom right corner. The second is the secondary diagonal − located from the top right to the bottom left corner. For a square matrix, if all the elements below the primary diagonal are zero, then it is called the Upper Triangular Matrix. # Example of upper triangular matrix matrix = [[1, 3, 4], ...
Read MorePython Program to Recursively Linearly Search an Element in an Array
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. When using a recursive function, we don't need any loop to generate iterations. The below syntax demonstrates the working of a simple recursion function ? def recursiveFunction(): # Statements # ... recursiveFunction() # ...
Read MorePython Program To Find the Trace and Normal of a given Matrix
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 is possible only for a square matrix (i.e., the matrix whose ...
Read MorePython Program to Multiply to Matrix Using Multi-dimensional Arrays
A matrix is a set of numbers arranged in rows and columns. A matrix with m rows and n columns is called an m × n matrix and m and n are called its dimensions. In Python, matrices can be created using lists or NumPy arrays. Matrix multiplication can be done in two ways: standard matrix multiplication (dot product) where the number of columns in the first matrix must equal the number of rows in the second matrix, and element-wise multiplication where matrices must have the same dimensions. Matrix Multiplication Types For standard matrix multiplication, if we ...
Read More