三级人工智能训练师试题

三级人工智能训练师试题

python 基础操作(字符串,集合,字典,99乘法表)

99乘法表实现

for i in range(1, 10):
    for j in range(1, 10):
        if j <= i:
            print(f"{j}×{i}={i*j}", end="\t")
    print()

99乘法表实现:请将填空处的___替换为正确的代码

for i in range(1, ___):
    for j in range(1, ___):
        if j <= ___:
            print(f"{j}×{i}={i*j}", end="        ")
    print()

Python字符串的创建及基本操作

## 创建字符串"str",内容为"student",并输出完整字符串
str = "student"
print(str)
预期输出: student
## 输出字符串中第3个字符
print(str[2])
预期输出: u

Python集合的创建及运算

创建元素为”1,2,3,4,5″的集合”s3″,元素为”3,4,5,6,7″的集合”s4″
s3 = {1, 2, 3, 4, 5}
s4 = {3, 4, 5, 6, 7}
print("s3:", s3)
print("s4:", s4)
预期输出:
s3: {1, 2, 3, 4, 5}
s4: {3, 4, 5, 6, 7}
分别计算s3和s4的交集,并集
print("s3和s4的交集:", s3 & s4)
print("s3和s4的并集:", s3 | s4)
预期输出:
s3和s4的交集: {3, 4, 5}
s3和s4的并集: {1, 2, 3, 4, 5, 6, 7}

Python字典的创建及基本操作

用dict函数创建空字典”dic4″,并输出结果
dic4 = dict()
print("dic4:", dic4)
预期输出: dic4: {}
直接赋值创建字典”dic2″,包含键值对{‘e’:1,’f’:2,’g’:3}
dic2 = {'e':1, 'f':2, 'g':3}
print("dic2:", dic2)
预期输出: dic2: {'e': 1, 'f': 2, 'g': 3}
删除字典dic2
del dic2
print("dic2已被删除")

综合应用

创建包含学生信息的字典

student = {
    "name": "张三",
    "age": 20,
    "courses": ["数学", "英语", "计算机"]
}
print(f"学生姓名: {student['name']}")
print(f"学生年龄: {student['age']}")
print(f"选修课程: {student['courses'][2]}")
## 预期输出:
## 学生姓名: 张三
## 学生年龄: 20
## 选修课程: 计算机

Python基础数据类型操作 – 实操考试

请将填空处的___替换为正确的代码

Python字符串的创建及基本操作

创建字符串”str”,内容为”student”,并输出完整字符串
str = "___"
print(str)
## 预期输出: student
## 输出字符串中第3个字符
print(str[___])
预期输出: u

Python集合的创建及运算

创建元素为”1,2,3,4,5″的集合”s3″,元素为”3,4,5,6,7″的集合”s4″
s3 = {1, 2, 3, 4, ___}
s4 = {3, ___, 5, 6, 7}
print("s3:", s3)
print("s4:", s4)
预期输出:
s3: {1, 2, 3, 4, 5}
s4: {3, 4, 5, 6, 7}
分别计算s3和s4的交集,并集
print("s3和s4的交集:", s3 ___ s4)
print("s3和s4的并集:", s3 ___ s4)
预期输出:
s3和s4的交集: {3, 4, 5}
s3和s4的并集: {1, 2, 3, 4, 5, 6, 7}

Python字典的创建及基本操作

用dict函数创建空字典”dic4″,并输出结果
dic4 = ___()
print("dic4:", dic4)
预期输出: dic4: {}
直接赋值创建字典”dic2″,包含键值对{‘e’:1,’f’:2,’g’:3}
dic2 = {'___':1, 'f':2, 'g':3}
print("dic2:", dic2)
预期输出: dic2: {'e': 1, 'f': 2, 'g': 3}
删除字典dic2
___ dic2
print("dic2已被删除")

综合应用

创建包含学生信息的字典

student = {
    "name": "张三",
    "age": ___,
    "courses": ["数学", "英语", "计算机"]
}
print(f"学生姓名: {student['name']}")
print(f"学生年龄: {student['age']}")
print(f"选修课程: {student['courses'][___]}")
## 预期输出:
## 学生姓名: 张三
## 学生年龄: 20
## 选修课程: 计算机

标注(分割,转录,分类)

艺术二维码

bqrbtf网

https://qrbtf.com/zh

一次性邮箱

https://temp-mail.org

西安宣传海报制作

AI网站:

https://chatglm.cn/

© 版权声明
THE END
喜欢就支持一下吧
点赞94 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容