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.

  1. Highest CPI from the class
  2. Lowest CPI from the class
  3. Average CPI of the class
  4. 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


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.