讲解这七道题目
Erstellt am: 24. Juni 2025
Erstellt am: 24. Juni 2025
讲解这七道题目
python1*2**3//4%5 2
pythona="Python 等级考试" len(a) 11
python0.1*0.1==0.01 False
pythonfrom PIL import Image import matplotlib.pyplot as plt img = Image.open('/mnt/data/IMG_20250624_124734.png') plt.imshow(img); plt.axis('off') (-0.5, 4094.5, 1110.5, -0.5)
pythonimg2 = Image.open('/mnt/data/Screenshot_2025-06-24-10-56-49-45_e39d2c7de19156b0683cd93e8735f348.jpg') plt.imshow(img2); plt.axis('off') (-0.5, 709.5, 447.5, -0.5)
pythonimg3 = Image.open('/mnt/data/Screenshot_2025-06-24-13-49-46-06_e39d2c7de19156b0683cd93e8735f348.jpg') plt.imshow(img3); plt.axis('off') (-0.5, 567.5, 420.5, -0.5)
pythonimg4 = Image.open('/mnt/data/Screenshot_2025-06-24-13-38-16-87_e39d2c7de19156b0683cd93e8735f348.jpg') plt.imshow(img4); plt.axis('off') (-0.5, 1474.5, 1071.5, -0.5)
pythonimg5 = Image.open('/mnt/data/Screenshot_2025-06-24-13-37-47-94_e39d2c7de19156b0683cd93e8735f348.jpg') plt.imshow(img5); plt.axis('off') (-0.5, 1088.5, 663.5, -0.5)
pythonimg6 = Image.open('/mnt/data/Screenshot_2025-06-24-13-37-15-62_e39d2c7de19156b0683cd93e8735f348.jpg') plt.imshow(img6); plt.axis('off') (-0.5, 966.5, 470.5, -0.5)
pythonimg7 = Image.open('/mnt/data/Screenshot_2025-06-24-13-30-28-02_e39d2c7de19156b0683cd93e8735f348.jpg') plt.imshow(img7); plt.axis('off') (-0.5, 1181.5, 986.5, -0.5)
下面是图片里 5 道不同 Python 选择题的逐题解析与正确答案。
(我只在截图中看到 5 个不同的代码片段。如果还有两题没列出,请再发过来,我再补充。)
x = 1*2**3//4%5
步骤 | 解释 | 结果 |
---|---|---|
2**3 | 幂运算最高优先级 | 8 |
1 * 8 | 乘法 | 8 |
8 // 4 | 整数(向下取整)除法 | 2 |
2 % 5 | 取余 | 2 |
答案:C. 2
x = 0x0011 ; print(x)
0x
开头的是十六进制字面量。0x11 = 1 × 16¹ + 1 × 16⁰ = 17
。print
输出十进制整数 17。答案:C. 17
pythons = 'I:LIKE:PYTHON' s.split(':')
str.split(sep)
会把原字符串按照分隔符拆分成 列表 list。['I', 'LIKE', 'PYTHON']
。答案:A. 列表 [...]
pythona = "Python 等级考试" b = "=" c = ">" print("{0:{1}{3}{2}}".format(a, b, 10, c))
{0:...}
表示用第 0 个参数 a
来填充。{1}
→ b
,即填充字符 '='
{3}
→ c
,即对齐符号 '>'
(右对齐){2}
→ 10
,即最小宽度 10"{0:= >10}"
a
的实际长度是 11(包含空格和 4 个中文字符),已经大于宽度 10,不会再填充,直接原样输出。最终输出:
Python 等级考试
答案:A. Python 等级考试
pythonprint(0.1 * 0.1 == 0.01)
0.010000000000000002
答案:B. False
format
高阶用法以及浮点精度。如果还有其他两道题目,请告诉我或补充截图,我会继续讲解!