From 64a2de73d8ef2a3160757570a946abeb46c2936a Mon Sep 17 00:00:00 2001 From: 2509165045 <2509165045@student.edu.cn> Date: Tue, 21 Apr 2026 11:30:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1 | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 1 diff --git a/1 b/1 new file mode 100644 index 0000000..2df5302 --- /dev/null +++ b/1 @@ -0,0 +1,39 @@ +#第一题 +for c in "Hello": + print(f"{c}:{ord(c)}") +#第二题 +print(chr(65)) +assert chr(65) =='A' +#思考题:“图像为数值化结构数据,适配计算架构;文本为语义化符号数据,需认知理解,超出当前AI本质能力。” +#第三题 +import numpy as np +A=np.array([3,4]) +B=np.array([1,2]) +c=A+B +d=A*2 +print(f"A+B={c}") +print(f"2*A={d}") +length = np.linalg.norm(A) +print(f"A的长度为{length}") +#第四题 + +C = np.array([1, 2, 3]) +D = np.array([4, 5, 6]) +dot = np.dot(C, D) +print(f"点积 = {dot}") +import numpy as np + +def cosine_similarity(C, D): + norm_a = np.linalg.norm(C) # 向量a的长度 + norm_b = np.linalg.norm(D) # 向量b的长度 + return dot / (norm_a * norm_b) +print(f"相似度 = {cosine_similarity(C, D):.3f}") + +E=np.array([1,0]) +F=np.array([0,1]) +def cosine_similarity(E, F): + norm_C = np.linalg.norm(E) # 向量a的长度 + norm_D = np.linalg.norm(F) # 向量b的长度 + return dot / (norm_C * norm_D) +print(f"相似度 = {cosine_similarity(E, F):.3f}") + \ No newline at end of file