线性代数 向量长度_用户定义长度的向量| 使用Python的线性代数
線性代數(shù) 向量長(zhǎng)度
Prerequisite: Defining a vector
先決條件: 定義向量
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.
線性代數(shù)是使用向量空間和矩陣的線性方程組的數(shù)學(xué)分支。 換句話說(shuō),向量是n維空間中只有一列的矩陣。 因此向量是線性代數(shù)的重要組成部分之一。 在以前的教程中,我們?cè)诖a本身中定義了向量。 在本教程中,我們將進(jìn)一步擴(kuò)展一步,以使用戶可以定義矢量的方式編寫代碼。
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.
關(guān)鍵點(diǎn):為了使代碼生成用戶定義的向量,我們需要一個(gè)主要參數(shù),即N。 N表示向量中元素的數(shù)量。
Python代碼定義用戶定義長(zhǎng)度的向量 (Python code to define a vector with user defined length)
# 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: 5 Enter the element: 12 Enter the element: 23 Enter the element: 31 Enter the element: 22 Enter the element: 56 Vector you defined = [12, 23, 31, 22, 56]RUN 2: Enter the length of the vector you want to define: 6 Enter the element: 33 Enter the element: 123 Enter the element: 9 Enter the element: 10 Enter the element: 98 Enter the element: 13 Vector you defined = [33, 123, 9, 10, 98, 13]翻譯自: https://www.includehelp.com/python/vector-with-user-defined-length.aspx
線性代數(shù) 向量長(zhǎng)度
總結(jié)
以上是生活随笔為你收集整理的线性代数 向量长度_用户定义长度的向量| 使用Python的线性代数的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 东星斑多少钱一斤啊?
- 下一篇: 在Python中将字符串拆分为字符数组