完成作业X

This commit is contained in:
2509165019
2026-04-21 11:24:07 +08:00
parent 57999c3b5a
commit f3077dc1f0
3 changed files with 40 additions and 0 deletions

11
test2.py Normal file
View 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)