logo

🧪 元组操作

⏱️ 15-20 min📊 Intermediate
main.py
Costs 1 credit
加载编辑器中...
输出 Output执行成功

[错误提示]
检测到中文全角符号(如 ( ) , : ;),Python 语法可能无法解析。
请改成英文半角符号:( ) , : ;
Terminal (Simulated)Install commands are simulated only, no real network requests
$

Step 1: 创建元组

元组适合表达“结构固定的记录”,比如坐标、颜色、日期。

底层逻辑:
元组是有序序列,支持索引访问,但创建后内容不可修改。
这让它在语义上更安全:读代码的人一眼就知道“这组值不该被改”。

你的任务

  1. 创建一个坐标点元组 point = (10, 20)
  2. 打印这个元组
  3. 分别打印 x 和 y 坐标(使用索引)

Self-Check List

  • 创建元组
  • 访问元组元素

Transfer Template

point = (10, 20)
print(point[0])  # x 坐标
After completing this step, you should be able to independently explain and reproduce this concept, then apply it to similar problems.

验证清单 (0/0)