Posts

Python Programming Looping Techniques, For Loop in Python Programming and While Loop in Python Programming | Python Programming

Image
Python Programming Looping Techniques, For Loop in Python Programming and While Loop in Python Programming For loop in Python Programming What is for loop in Python Programming? The for loop in Python Programming is used to iterate over a sequence (list, tuple, string) or other iterable objects. Iterating over a sequence is called traversal. Syntax of for Loop for val in sequence:     Body of for Here, val is the variable that takes the value of the item inside the sequence on each iteration. Loop continues until we reach the last item in the sequence. The body of for loop is separated from the rest of the code using indentation. Flowchart of for Loop Example: Python for Loop # Program to find the sum of all numbers stored in a list # List of numbers numbers = [ 6 , 5 , 3 , 8 , 4 , 2 , 5 , 4 , 11 ] # variable to store the sum sum = 0 # iterate over the list for val in numbers:     sum = sum +val # Output: The sum is 48 print ( "The sum is" , sum ) when you run th

Python Programming Namespace | Python Programming

Image
What is Name in Python Programming? A namespace is a system to have a unique name for each and every object in Python. An object might be a variable or a method. Python itself maintains a namespace in the form of a Python dictionary.  Namespaces are one honking great idea -- let's do more of those!  

Python Programming Type Casting/Conversion, Frozen Set | Python Programming

Python Programming Type Casting/Conversion: The process of converting the value of one data type such as integer, string, float, etc. to another data type is called type conversion/ typecasting. Python has two types of type conversion/typecasting. Implicit Type Conversion Explicit Type Casting

C Program for Insertion Sort | C Programming

C Program For Insertion Sort Using time.h Function and Generating Random Number #include <math.h> #include <time.h> #include <stdlib.h> #include <stdio.h> void insertionSort ( int arr [], int n ) {     int i , key , j ;     for ( i = 1 ; i < n ; i ++)     {         key = arr [ i ];         j = i - 1 ;         while ( j >= 0 && arr [ j ] > key )         {             arr [ j + 1 ] = arr [ j ];             j = j - 1 ;         }         arr [ j + 1 ] = key ;     } } void printArray ( int arr [], int n ) {     int i ;     for ( i = 0 ; i < n ; i ++)         printf ( " %d  " , arr [ i ]);     printf ( " \n " ); } int main () {     int arr [ 100 ], n , i ;     time_t t ;     printf ( "Enter the max number \n " );     scanf ( " %d " , & n );     srand (( unsigned ) time (& t ));     for ( i = 0 ; i < n ; i ++)     {         arr [ i ] = rand () % 100 ;     }    

Eigen Values and Eigen Vectors

Eigenvalues Eigenvalues are a special set of scalars associated with a linear system of equation (i.e., a matrix equation) that are sometimes also known as characteristic roots, characteristic values, proper values, or latent roots.

Doolittle Algorithm: LU Decomposition Algorithm

Image
DOOLITTLE Algorithm In the numerical method Doolittle Algorithm : LU Decomposition Algorithm (where LU stands for Lower and Upper and also called LU factorization Algorithm) factors a matrix as the product of a lower triangular matrix and an upper triangular matrix. Computers usually solve square systems of linear equations using the LU decomposition, and it is also a key step when inverting a matrix, or computing the determinant of a matrix. Let A be a square matrix. An LU factorization algorithm refers to the factorization of A, with proper row and/or column orderings or permutations, into two factors, a lower triangular matrix L and an upper triangular matrix U,  A=LU . Assume that  A  has a Crout factorization  A  =  LU . 

Improved Euler's Method and Euler's Method with their C Program

Image
Improved Euler’s Method The Improved Euler’s method, also known as the Heun formula or the average slope method, gives a more accurate approximation than the Euler rule and gives an explicit formula for computing  y n+1 . The basic idea is to correct some errors of the original Euler's method. The syntax of the Improved Euler’s method is similar to that of the trapezoid rule, but the  y  value of the function in terms of  y n+1  consists of the sum of the  y  value and the product of  h  and the function in terms of  x n  and  y n .