Home » Python » Linear Algebra using Python

# Python | Application to School CPI Records (Linear Algebra)

Linear Algebra using Python: Implementing an application to school CPI records in Python.

Submitted by Anuj Singh, on July 07, 2020

Linear algebra is the branch of mathematics concerning linear equations by using vector spaces and through matrices. In other words, a vector is a matrix in n-dimensional space with only one column. So vector is one of the important constituents for linear algebra. In this tutorial, we are going to learn how to apply vectors for simple applications such as marks of the students. Numpy provides us a complete package of inbuilt functions that provide us a free hand to perform different manipulations with our vector to our application.

Firstly, we will store the CPIs of all the students of class X in a school, and after that, we are going to analyze the Class Statistics using inbuilt functions.

- Highest CPI from the class
- Lowest CPI from the class
- Average CPI of the class
- Variance of the class

Following is the python code for demonstration,

# Linear Algebra Learning Sequence # Basic Application import numpy as np stun = int(input('Number of students in all section of Class X : ')) srl = np.arange(stun) cpi = np.array([]) for i in range(stun): print('Enter the CPI of',i,' student : ') cp = float(input()) cpi = np.append(cpi, cp) for i in range(stun): print('Student ',srl[i]+1, ': ', cpi[i]) print('Highest from class X : ', np.max(cpi)) print('Lowest from class X : ', np.min(cpi)) print('Average from class X : ', np.mean(cpi)) print('Variance from class X : ', np.var(cpi))

**Output:**

Number of students in all section of Class X : 5 Enter the CPI of 0 student : 4.2 Enter the CPI of 1 student : 4.3 Enter the CPI of 2 student : 3.2 Enter the CPI of 3 student : 3.3 Enter the CPI of 4 student : 5.5 Student 1 : 4.2 Student 2 : 4.3 Student 3 : 3.2 Student 4 : 3.3 Student 5 : 5.5 Highest from class X : 5.5 Lowest from class X : 3.2 Average from class X : 4.1 Variance from class X : 0.692

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions

**Ad:**
Are you a blogger? Join our Blogging forum.