Files
task-3-2-1-Text-Processing-…/260421_2509165028.py
2509165028 dbec1f2237 3-2-1
2026-04-21 11:34:07 +08:00

19 lines
518 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import numpy as np
# 第一部分题目1
s="Hello"
print("ASCII码分别为",[ord(o) for o in s])
print(f"ASCII码65对应的字符是{chr(65)}")
# 第二部分题目3
A=np.array([3,4])
B=np.array([1,2])
print(f"计算A+B的结果为{A+B}")
print(f"计算A*2的结果为{A*2}")
length=np.linalg.norm(A)
print(f"向量A的长度为{length}")
# 第二部分题目4
A=np.array([1,2,3])
B=np.array([4,5,6])
dot=np.dot(A,B)
print(f"A·B点积为{dot}")
print(f"相似度 = {cosine_similarity(A, B):.3f}")