diff --git "a/16 \347\250\213\345\255\220\351\276\231/20260527.py" "b/16 \347\250\213\345\255\220\351\276\231/20260527.py" new file mode 100644 index 0000000000000000000000000000000000000000..715c3af6f796211fc9025b8d24ef2cacc4c38ede --- /dev/null +++ "b/16 \347\250\213\345\255\220\351\276\231/20260527.py" @@ -0,0 +1,42 @@ +# ### A组:基础必做 +# +# 1. 创建列表保存 5 个学生姓名并遍历输出。 +# students = ["胡宇", "子涵", "欧阳", "非阴", "子龙"] +# for student in students: +# print(students) + +# 2. 创建字典保存一个学生的姓名、年龄、成绩。 +# hu_yu = { +# "name": "胡宇", +# "age": 19, +# "score": 59 +# } +# print(hu_yu) + +# 3. 创建集合去除重复课程名称。 +# course = {"语文", "数学", "英语", "化学", "物理", "地理", "生物", "政治", "历史", "地理", "化学"} +# print(course) + +# 4. 统计列表中元素个数。 +# num = [5, 2, 0, 1, 3, 1, 4, 9, 1, 7, 8, 6, 9] +# print(len(num)) + +# ### B组:巩固提升 +# +# 1. 使用列表保存 5 个成绩,计算平均分。 +# scores = [88, 100, 91, 78, 59] +# total = 0 +# for score in scores: +# total += score +# print(total) + +# 2. 使用字典保存商品信息,并计算折后价格。 +# vip = 0.99 +# names = { +# "电风扇": 50, +# "拖孩": 9.9, +# "屁股手机": 10000 +# } +# print(names["电风扇"] * vip) +# print(names["拖孩"] * vip) +# print(names["屁股手机"] * vip) \ No newline at end of file