线性代数 python
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.
线性代数是使用向量空间和矩阵的线性方程组的数学分支。 换句话说,向量是n维空间中只有一列的矩阵。 因此向量是线性代数的重要组成部分之一。 在本教程中,我们将学习如何将向量应用于简单的应用程序,例如学生的成绩。 Numpy为我们提供了完整的内置函数包,使我们可以自由使用矢量对应用程序执行不同的操作。
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.
首先,我们将存储学校中所有X类学生的CPI,然后,我们将使用内置函数来分析Class Statistics。
Highest CPI from the class
同类中最高的CPI
Lowest CPI from the class
同类中最低的CPI
Average CPI of the class
班级平均CPI
Variance of the class
班级差异
Following is the python code for demonstration,
以下是用于演示的python代码,
# 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
线性代数 python