完成作业3-2-1

This commit is contained in:
2509165016
2026-04-21 11:29:15 +08:00
parent 37553257a8
commit b936c0ca34
2 changed files with 35 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
import math
A = [3, 4]
B = [1, 2]
# 1. A + B
add_result = [a + b for a, b in zip(A, B)]
print("A + B =", add_result)
# 2. 2 × A
scalar_result = [2 * a for a in A]
print("2 × A =", scalar_result)
# 3. A的长度
norm = math.sqrt(sum(a**2 for a in A))
print("A的长度 =", norm)