This commit is contained in:
2509165029
2026-04-21 11:35:12 +08:00
parent df71af4502
commit f10cebebdf
8 changed files with 71 additions and 0 deletions

3
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

1
.idea/.name generated Normal file
View File

@@ -0,0 +1 @@
4.21.py

View File

@@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

4
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/task-3-2-1-Text-Processing-Introduction.iml" filepath="$PROJECT_DIR$/.idea/task-3-2-1-Text-Processing-Introduction.iml" />
</modules>
</component>
</project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

35
4.21.py Normal file
View File

@@ -0,0 +1,35 @@
s = "Hello"
print("1. 字符 ASCII 码:")
for ch in s:
print(f" '{ch}' -> {ord(ch)}")
print("\n2. 验证 chr(65):")
print(f" chr(65) = '{chr(65)}'")
A = [3, 4]
B = [1, 2]
def add_vectors(v1, v2):
return [v1[0] + v2[0], v1[1] + v2[1]]
def scalar_multiply(scalar, v):
return [scalar * v[0], scalar * v[1]]
import math
def vector_length(v):
return math.sqrt(v[0]**2 + v[1]**2)
print("\n3. 向量计算:")
print(f" A = {A}")
print(f" B = {B}")
print(f" A + B = {add_vectors(A, B)}")
print(f" 2 × A = {scalar_multiply(2, A)}")
print(f" A 的模 = {vector_length(A)}")