完成作业X
This commit is contained in:
11
test2.py
Normal file
11
test2.py
Normal file
@@ -0,0 +1,11 @@
|
||||
A = [3, 4]
|
||||
B = [1, 2]
|
||||
A_plus_B = [A[i] + B[i] for i in range(len(A))]
|
||||
print("1. A + B =", A_plus_B)
|
||||
two_mul_A = [2 * x for x in A]
|
||||
print("2. 2 * A =", two_mul_A)
|
||||
import math
|
||||
def vector_norm(v):
|
||||
return math.sqrt(sum(x ** 2 for x in v))
|
||||
A_norm = vector_norm(A)
|
||||
print("3. A 的模 =", A_norm)
|
||||
Reference in New Issue
Block a user