Posts

Function In Python Programming | Python Programming

What is a function in Python? In Python, a function is a group of related statements that perform a specific task. Functions help break our program into smaller and modular chunks. As our program grows larger and larger, functions make it more organized and manageable. Furthermore, it avoids repetition and makes code reusable. You can define functions to provide the required functionality. Here are simple rules to define a function in Python. Function blocks begin with the keyword  def  followed by the function name and parentheses ( ( ) ). Any input parameters or arguments should be placed within these parentheses. You can also define parameters inside these parentheses. The first statement of a function can be an optional statement – the documentation string of the function or  docstring . The code block within every function starts with a colon (:) and is indented. The statement return [expression] exits a function, optionally passing back an expression to the ca

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 .