From 821a533bfa22ab50778877b765382a0270102d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E6=AC=A3=E6=80=A1?= <2509165012@student.example.com> Date: Thu, 23 Apr 2026 15:56:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- numpy.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 numpy.py diff --git a/numpy.py b/numpy.py new file mode 100644 index 0000000..46acef4 --- /dev/null +++ b/numpy.py @@ -0,0 +1,20 @@ +import numpy as np + +print("=" * 50) +print("向量加法演示") +print("=" * 50) + +a = np.array([1, 2, 3]) +b = np.array([4, 5, 6]) +c = a + b + +print(f"向量 a = {a}") +print(f"向量 b = {b}") +print(f"a + b = {c}") +print() +print("计算过程:") +print(f" 位置0: {a[0]} + {b[0]} = {a[0]+b[0]}") +print(f" 位置1: {a[1]} + {b[1]} = {a[1]+b[1]}") +print(f" 位置2: {a[2]} + {b[2]} = {a[2]+b[2]}") +print() +print("验证:", a[0]+b[0] == c[0], a[1]+b[1] == c[1], a[2]+b[2] == c[2]) \ No newline at end of file