本文共 1568 字,大约阅读时间需要 5 分钟。
线性代数 向量长度
Prerequisite:
先决条件:
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 previous tutorials, we defined the vector in code itself. In this tutorial, we will just extend one step more to make a code in a way that users can define a vector.
线性代数是使用向量空间和矩阵的线性方程组的数学分支。 换句话说,向量是n维空间中只有一列的矩阵。 因此向量是线性代数的重要组成部分之一。 在以前的教程中,我们在代码本身中定义了向量。 在本教程中,我们将进一步扩展一步,以使用户可以定义矢量的方式编写代码。
Keypoint: For a code to generate a user-defined vector, we need one major parameter i.e. N. N represents the number of elements in a vector.
关键点:为了使代码生成用户定义的向量,我们需要一个主要参数,即N。 N表示向量中元素的数量。
# Vectors in Linear Algebra Sequnce # Vector with User Defined Lengthn = int(input("Enter the length of the vector you want to define: "))v = []for i in range(n): v.append(int(input('Enter the element: '))) print("Vector you defined = ", v)
Output:
输出:
RUN 1:Enter the length of the vector you want to define: 5Enter the element: 12Enter the element: 23Enter the element: 31Enter the element: 22Enter the element: 56Vector you defined = [12, 23, 31, 22, 56]RUN 2:Enter the length of the vector you want to define: 6Enter the element: 33Enter the element: 123Enter the element: 9Enter the element: 10Enter the element: 98Enter the element: 13Vector you defined = [33, 123, 9, 10, 98, 13]
翻译自:
线性代数 向量长度
转载地址:http://tixzd.baihongyu.com/