Posts

Showing posts from September, 2026

How to solve a system of linear equations using Numpy?

              System of linear equations have a set of equations with same variable. It has a solution of values which suits all the equations. It can be done by input validation, error handling. Let us create a python program to solve this. Code: import numpy as np def solveIt_linear_system():     try:         # Input statement         n = int(input("Enter the number of equations/variables: "))         if n <= 0:             print("Number of equations must be positive.")             return         # Read the coefficient matrix         print(f"Enter the {n}x{n} coefficient matrix (row by row):")      ...

Aggregations on matrix in Python

               Aggregations are the data transformation techniques which produces scalar values from arrays. Let us implement this two ways 1.       Using python code 2.       Using Numpy The code is given below… 1.Using python code:               This method creates a matrix.It calculates the row wise sum,column wise sum and overall sum. It also finds the maximum value in row wise and column wise. Finally,it displays the values. Code: s_matrix = [     [2, 2, 1],     [6, 5, 4],     [3, 8, 9] ] # Let us find Row-wise sum row_sums = [sum(row) for row in s_matrix] # Let us find Column-wise sum col_sums = [sum(s_matrix[r][c] for r in range(len(s_matrix))) for c in range(len(s_matrix[0]))] # Sum of all the elements total_sum = sum(sum(row) for row in s_ma...

Advance functions for Random number generation in Python

               Random Number generation can be categoried into three categories. Part1 describes the basic type. Part2 deals with the probability distributions. Part3 covers the advanced Random number Generation. To read the part1,part2,just follow the link. https://rajeeva84.blogspot.com/2026/08/random-number-generation-in-python.html https://rajeeva84.blogspot.com/2026/08/random-number-generation-in-python_02076504341.html Advanced methods are given below… ·        Random State / Seed ·        Cryptographically Secure Randoms 1.Random State/Seed:               It uses ‘seed()’ method. This helps to initialize the generator. As a default value,it seeds the current system time. First method uses randint() function to print random value. Second method uses seed() method. Python code: import random # Wi...