25级数应四班第三次实验(32)
| 学号 | 姓名 | 是否提交作业 |
| 2025010133 | 王子涵 | 是 |
| 2025010134 | 赵雯佳 | 是 |
| 2025010136 | 屈雨蒙 | 是 |
| 2025010137 | 刘柯凡 | 是 |
| 2025010139 | 潘佳乐 | 是 |
| 2025010140 | 杨亚洲 | 是 |
| 2025010141 | 王嘉伟 | 是 |
| 2025010142 | 杨旭洁 | 是 |
| 2025010143 | 肖雅楠 | 是 |
| 2025010144 | 张博洋 | 是 |
| 2025010145 | 黄冰冰 | 是 |
| 2025010146 | 顾芳菲 | 是 |
| 2025010147 | 刘芝怡 | 否 |
| 2025010148 | 岳嘉瑞 | 是 |
| 2025010149 | 马相淼 | 否 |
| 2025010150 | 唐景泽 | 是 |
| 2025010151 | 侯益波 | 是 |
| 2025010152 | 刘金惺 | 是 |
| 2025010153 | 范鹏展 | 是 |
| 2025010154 | 洪关瑞 | 是 |
| 2025010155 | 王状 | 是 |
| 2025010157 | 闫宸熙 | 是 |
| 2025010158 | 陈文洁 | 是 |
| 2025010159 | 成哲煜 | 否 |
| 2025010160 | 韩俊杰 | 是 |
| 2025010161 | 朱星月 | 是 |
| 2025010162 | 刘奕桐 | 是 |
| 2025010163 | 刘志杰 | 是 |
| 2025010164 | 李朋祖 | 是 |
| 2025010165 | 赵子月 | 是 |
| 2025010166 | 蒋子凡 | 是 |
| 2025010167 | 杨书宇 | 是 |
| 2025010168 | 袁艺伦 | 是 |
| 2025010169 | 闵子怡 | 是 |
| 2025010170 | 张家祺 | 是 |
| 2025010171 | 陈宣汝 | 是 |
| 2025010172 | 张景悦 | 是 |
| 2025010173 | 杨云飞 | 是 |
| 2025010174 | 刘研 | 是 |
| 2025010175 | 孙兰妮 | 是 |
2025010133王子涵
# 图书表:列表里放多个图书字典
book_list = [
{"编号": "1001", "名称": "Python入门", "出版商": "机械工业", "价格": 49.8},
{"编号": "1002", "名称": "C语言程序设计", "出版商": "清华大学", "价格": 39.9},
{"编号": "1003", "名称": "数据结构", "出版商": "电子工业", "价格": 59.0}
]
# 显示当前所有图书
print("当前图书表:")
for book in book_list:
print(book)
# 获取用户输入
del_id = input("\n请输入要删除的图书编号:")
del_name = input("请输入要删除的图书名称:")
del_pub = input("请输入要删除的图书出版商:")
# 查找并删除
found = False
for book in book_list:
if (book["编号"] == del_id and
book["名称"] == del_name and
book["出版商"] == del_pub):
book_list.remove(book)
found = True
print("\n删除成功!")
break
if not found:
print("\n未找到匹配的图书,删除失败")
# 显示删除后结果
print("\n删除后的图书表:")
for book in book_list:
print(book)
![第三次作业图]()
2025010134 赵雯佳
# 初始列表
lst = [54, 36, 75, 28, 50]
print("初始列表:", lst)
# (1) 尾部插入52
lst.append(52)
print("(1) 尾部插入52后:", lst)
# (2) 在28前插入66
idx = lst.index(28)
lst.insert(idx, 66)
print("(2) 在28前插入66后:", lst)
# (3) 删除并输出28
idx = lst.index(28)
removed = lst.pop(idx)
print("(3) 删除的元素:", removed)
print("(3) 删除28后列表:", lst)
# (4) 降序排序
lst.sort(reverse=True)
print("(4) 降序排序后:", lst)
# (5) 清空列表
lst.clear()
print("(5) 清空后:", lst)

2025010136 屈雨蒙
加载图片
import matplotlib.pyplot as plt
from PIL import Image
img = Image.open(r"C:\Users\huawei\Desktop\1.jpg")
plt.imshow(img)
plt.axis("off")
plt.show()

2025010137 刘柯凡
筛选出发车次
train = [
["T40", "长春-北京", "00:12", "12:20", "12:08"],
["T298", "长春-北京", "00:06", "10:50", "10:44"],
["Z158", "长春-北京", "12:48", "21:06", "08:18"],
["Z62", "长春-北京", "21:58", "08:18", "08:20"]
]
print("8:00 ~ 12:00 出发的车次:\n")
for item in train:
dep_time = item[2]
hour = int(dep_time.split(":")[0])
if 8 <= hour <= 12:
print("\t".join(item))

2025010139 潘佳乐
院系字典
ankang_university = {
"01": "计算机科学与技术",
"02": "电子信息工程",
"03": "汉语言文学",
"04": "英语",
"05": "会计学",
"06": "财务管理",
"07": "护理学",
"08": "学前教育",
"09": "机械设计制造及其自动化",
"10": "土木工程"
}
students = [
{"学号": "2025001", "姓名": "张三", "专业编号": "01", "专业": ankang_university["01"]},
{"学号": "2025002", "姓名": "李四", "专业编号": "01", "专业": ankang_university["01"]},
{"学号": "2025003", "姓名": "王五", "专业编号": "02", "专业": ankang_university["02"]},
{"学号": "2025004", "姓名": "赵六", "专业编号": "03", "专业": ankang_university["03"]},
{"学号": "2025005", "姓名": "孙七", "专业编号": "03", "专业": ankang_university["03"]},
{"学号": "2025006", "姓名": "周八", "专业编号": "03", "专业": ankang_university["03"]},
{"学号": "2025007", "姓名": "吴九", "专业编号": "05", "专业": ankang_university["05"]},
{"学号": "2025008", "姓名": "郑十", "专业编号": "05", "专业": ankang_university["05"]},
{"学号": "2025009", "姓名": "冯十一", "专业编号": "07", "专业": ankang_university["07"]},
{"学号": "2025010", "姓名": "陈十二", "专业编号": "10", "专业": ankang_university["10"]},
]
print("=" * 60)#打印等号
print("安康学院学生信息表")
print("=" * 60)#打印等号
print(f"{'学号':<10}{'姓名':<8}{'专业'}")
print("-" * 60)#打印——号
for stu in students:#逐个取出学生
print(f"{stu['学号']:<10}{stu['姓名']:<8}{stu['专业']}")#循环打印
major_count = {}#统计专业人数
for stu in students:
major = stu["专业"]#遍历每个学生,拿到他的专业名
if major in major_count:
major_count[major] += 1#专业在字典里人数+1
else:
major_count[major] = 1#专业不在字典里设为1
print("\n" + "=" * 60)
print("安康学院各专业人数统计")
print("=" * 60)
print(f"{'专业名称':<25}{'人数'}")
print("-" * 60)
for major, count in major_count.items():
print(f"{major:<25}{count}")#一对一对齐好看
print("-" * 60)
print(f"{'总计':<25}{len(students)}")#求总人数


2025010140杨亚洲
tank = ["苏烈","刘邦","钟馗","张飞","牛魔","程咬金","白起","刘禅","庄周","项羽","廉颇","巨灵神","安禄山","猪八戒","赵云"]
warrior = ["狂铁","裴擒虎","铠","孙悟空","哪吒","杨戬","橘右京","亚瑟","雅典娜","夏侯惇","关羽","吕布","韩信","老夫子","达摩","典韦","曹操","钟无艳","墨子","赵云"]
assassin = ["百里玄策","庞统","花木兰","阿轲","不知火舞","李白","娜可露露","兰陵王","露娜","韩信","宫本武藏","赵云"]
mage = ["甄姬","嬴政","干将莫邪","妲己","安琪拉","貂蝉","小乔","大乔","诸葛亮"]
archer = ["公孙离","百里守约","后羿","黄忠","马可波罗","成吉思汗","虞姬","李元芳","艾琳","狄仁杰","鲁班七号","孙尚香"]
support = ["明世隐","梦奇","孙膑","太乙真人","蔡文姬","诸葛亮"]
all_hero = tank + warrior + assassin + mage + archer + support
repeat = []
for i in all_hero:
if all_hero.count(i) > 1 and i not in repeat:
repeat.append(i)
print(i)![屏幕截图 2026-06-04 213832]()
2025010141王嘉伟
# 简易井字棋
# 棋盘
board = ['1', '2', '3',
'4', '5', '6',
'7', '8', '9']
# 打印棋盘
def print_board():
print(board[0] + '|' + board[1] + '|' + board[2])
print('-+-+-')
print(board[3] + '|' + board[4] + '|' + board[5])
print('-+-+-')
print(board[6] + '|' + board[7] + '|' + board[8])
# 判断输赢
def check_win():
# 所有赢的情况
win = [[0,1,2],[3,4,5],[6,7,8],
[0,3,6],[1,4,7],[2,5,8],
[0,4,8],[2,4,6]]
for w in win:
if board[w[0]] == board[w[1]] == board[w[2]]:
return True
return False
# 判断平局
def is_full():
for i in board:
if i.isdigit():
return False
return True
# 开始游戏
print("欢迎来玩井字棋!你是 X,电脑是 O")
print_board()
while True:
# 你下棋
choice = input("请输入数字(1-9):")
pos = int(choice) - 1
board[pos] = 'X'
print_board()
# 检查你赢没
if check_win():
print("你赢啦!")
break
# 平局
if is_full():
print("平局!")
break
# 电脑随便找个空位置下
for i in range(9):
if board[i].isdigit():
board[i] = 'O'
break
print("电脑下完了:")
print_board()
# 检查电脑赢没
if check_win():
print("电脑赢了!")
break
if is_full():
print("平局!")
break
![1]()
2025010142 杨旭洁
找出车次中含8的
trains = {
"T40": ["长春-北京", "00:12", "12:20"],
"T298": ["长春-北京", "00:06", "10:50"],
"Z158": ["长春-北京", "12:48", "21:06"],
"Z62": ["长春-北京", "21:58", "08:18"]
}
print("含8的车次:")
for c in trains.keys():
if "8" in c:
print(c)
print("车次\t出发-到达\t出发时间")
for k, v in trains.items():
print(k, v[0], v[1], sep="\t")
# no = input("请输入购买车次:")
# user = input("请输入乘车人(用逗号分隔):")
# print(f"你已购买{no}次列车从{trains[no][0]}{trains[no][1]}开,请{user}尽快换取纸质车票。【铁路客服】")

2025010143 肖雅楠
list = [54, 36, 75, 28, 50]
list.append(52)
print(list) # 输出: [54, 36, 75, 28, 50, 52]

list = [54, 36, 75, 28, 50, 52]
# 找到28的索引位置为3,在索引3处插入66
list.insert(3, 66)
print(list) # 输出: [54, 36, 75, 66, 28, 50, 52]

list = [54, 36, 75, 66, 28, 50, 52]
# 找到28的索引位置为4,弹出该位置元素
elem = list.pop(4)
print(elem) # 输出: 28
print(list) # 输出: [54, 36, 75, 66, 50, 52]

list = [54, 36, 75, 66, 50, 52]
list.sort(reverse=True)
print(list) # 输出: [75, 66, 54, 52, 50, 36]

list = [54, 36, 75, 28, 50]
list.append(52)
print(list) # 输出: [54, 36, 75, 28, 50, 52]

2025010144张博洋
text = "肖申克的救赎 肖申克的救赎值得反复看 肖申克的救赎"
words = text.split()
freq = {}
for word in words:
freq[word] = freq.get(word, 0) + 1
# 找最多的词
max_word = max(freq, key=freq.get)
print(f"出现最多:'{max_word}',{freq[max_word]}次")
print(f"完整统计:{freq}")

2025010145 黄冰冰
# 定义三个集合 Pythonset = {'王海', '李黎明', '王铭年', '李晗'} Cset = {'朱佳', '李黎明', '王铭年', '杨鹏'} Javaset = {'王海', '杨鹏', '王铭年', '罗明', '李晗'} # 只会Python不会C的人:差集运算 only_python = Pythonset - Cset # 三种语言都会的人:交集运算 all_three = Pythonset & Cset & Javaset # 输出结果 print("只会Python不会C的人:", only_python) print("三种语言都会的人:", all_three)
2025010146 顾芳菲
学生表课程表成绩表合并
# 1. 学生表(列表里存字典)
students = [
{"学号": "001", "姓名": "张三"},
{"学号": "002", "姓名": "李四"},
{"学号": "003", "姓名": "王五"}
]
# 2. 课程表
courses = [
{"课程编码": "K001", "课程名": "Python"},
{"课程编码": "K002", "课程名": "数据库"},
{"课程编码": "K003", "课程名": "数学"}
]
# 3. 成绩表
scores = [
{"学号": "001", "课程编码": "K001", "成绩": 90},
{"学号": "001", "课程编码": "K002", "成绩": 85},
{"学号": "002", "课程编码": "K001", "成绩": 92},
{"学号": "003", "课程编码": "K003", "成绩": 88}
]
# 4. 合并结果(只保留 学号、课程编码、成绩)
result = []
for s in scores:
merged = {
"学号": s["学号"],
"课程编码": s["课程编码"],
"成绩": s["成绩"]
}
result.append(merged)
# 打印三张表和合并结果
print("学生表: ")
for stu in students:
print(stu)
print("\n课程表: ")
for cou in courses:
print(cou)
print("\n成绩表: ")
for sco in scores:
print(sco)
print("\n合并后的结果(学号、课程编码、成绩): ")
for r in result:
print(r)

2025010147刘芝怡百钱买百鸡
# 百钱买百鸡:公鸡5钱1只,母鸡3钱1只,小鸡1钱3只
# 求:100钱买100只鸡,公鸡x、母鸡y、小鸡z各多少只
for x in range(0, 21):
for y in range(0, 34):
z = 100 - x - y
if z % 3 == 0:
if 5 * x + 3 * y + z // 3 == 100:
print(f"公鸡:{x} 只,母鸡:{y} 只,小鸡:{z} 只")

2025010148 岳嘉瑞 统计院系人数
# ======================
# 数学与统计学院 专业+学生表格
# ======================
# 格式:[专业, 学生姓名]
students = [
["数学与应用数学", "张三"],
["数学与应用数学", "李四"],
["统计学", "王五"],
["统计学", "赵六"],
["数学与应用数学", "钱七"]
]
# 打印院系表格
print("=" * 45)
print(f"{'数学与统计学院院系表格':^45}")
print("=" * 45)
print(f"{'序号':<5}{'专业':<15}{'学生姓名':<10}")
print("-" * 45)
for i, (major, name) in enumerate(students, 1):
print(f"{i:<5}{major:<15}{name:<10}")
print("=" * 45)
# ======================
# 单独学生姓名表格
# ======================
print()
print("=" * 25)
print(f"{'学生姓名表格':^25}")
print("=" * 25)
print(f"{'序号':<5}{'学生姓名':<10}")
print("-" * 25)
for i, (_, name) in enumerate(students, 1):
print(f"{i:<5}{name:<10}")
print("=" * 25)
# ======================
# 统计各专业人数
# ======================
print()
print("=" * 25)
print(f"{'专业人数统计':^25}")
print("=" * 25)
math_count = 0
stat_count = 0
for major, _ in students:
if major == "数学与应用数学":
math_count += 1
elif major == "统计学":
stat_count += 1
print(f"数学与应用数学:{math_count} 人")
print(f"统计学 :{stat_count} 人")
print("-" * 25)
print(f"总人数 :{math_count + stat_count} 人")
print("=" * 25)
2025010150唐景泽
student_class = {
"a": "1班",
"b": "1班",
"c": "1班",
"d": "2班",
"e": "2班",
"f": "2班",
"g": "3班",
"h": "3班",
"i": "3班"
}
scores = {
"a": [80, 85, 90],
"b": [70, 75, 80],
"c": [90, 95, 88],
"d": [65, 70, 72],
"e": [88, 92, 95],
"f": [75, 78, 80],
"g": [55, 60, 65],
"h": [82, 85, 88],
"i": [70, 72, 74]
}
student_avg = {}
for s in scores:
avg = sum(scores[s]) / len(scores[s])
student_avg[s] = avg
class_scores = {"1班": [], "2班": [], "3班": []}
for s in student_class:
cls = student_class[s]
class_scores[cls].append(student_avg[s])
class_avg = {}
for cls in class_scores:
avg = sum(class_scores[cls]) / len(class_scores[cls])
class_avg[cls] = avg
result = []
for s in student_class:
cls = student_class[s]
if student_avg[s] > class_avg[cls]:
result.append((s, cls, round(student_avg[s],2), round(class_avg[cls],2)))
print("===== 班级平均分 =====")
for cls, avg in class_avg.items():
print(f"{cls} 平均分:{round(avg,2)}")
print("\n===== 个人平均分大于所在班级平均分的同学 =====")
for item in result:
print(f"同学{item[0]}|{item[1]}|个人平均分:{item[2]}|班级平均分:{item[3]}")

2025010151侯益波
poet_data = [
{
"朝代": "唐代",
"诗人作品": {
"李白": 1010,
"杜甫": 1400,
"白居易": 3009,
"王维": 400,
"孟浩然": 200,
"王昌龄": 180,
"岑参": 403,
"高适": 200,
"李商隐": 600,
"杜牧": 500,
"刘禹锡": 700,
"柳宗元": 164
}
},
{
"朝代": "宋代",
"诗人作品": {
"陆游": 9242,
"苏轼": 2700,
"王安石": 1500,
"黄庭坚": 1900,
"杨万里": 4200,
"范成大": 1900,
"辛弃疾": 620,
"李清照": 70
}
},
{
"朝代": "魏晋南北朝",
"诗人作品": {
"陶渊明": 125,
"曹植": 90,
"谢灵运": 100
}
},
{
"朝代": "元代",
"诗人作品": {
"元好问": 1380
}
},
{
"朝代": "明代",
"诗人作品": {
"高启": 2000
}
},
{
"朝代": "清代",
"诗人作品": {
"乾隆": 43000,
"袁枚": 4000,
"纳兰性德": 348,
"龚自珍": 600
}
}
]
print("===== 各诗人作品明细 =====")
for dynasty in poet_data:
print(f"\n【{dynasty['朝代']}】")
for name, count in dynasty["诗人作品"].items():
print(f"{name}:{count} 首")
print("\n\n===== 各朝代统计汇总 =====")
for dynasty in poet_data:
name_dict = dynasty["诗人作品"]
poet_num = len(name_dict)
work_total = sum(name_dict.values())
print(f"{dynasty['朝代']}:诗人{poet_num}位,作品总共{work_total}首")
all_poet = 0
all_work = 0
for dynasty in poet_data:
all_poet += len(dynasty["诗人作品"])
all_work += sum(dynasty["诗人作品"].values())
print("\n===== 全局总统计 =====")
print(f"全部朝代合计:诗人{all_poet}位,作品总共{all_work}首")

2025010152刘金惺
import os
import tkinter as tk
from tkinter import ttk, filedialog
import pygame
# 初始化音频模块
pygame.mixer.init()
class MusicPlayer:
def __init__(self, root):
self.root = root
self.root.title("简易音乐播放器")
self.root.geometry("500x400")
# 变量
self.music_list = []
self.current_idx = 0
self.is_pause = False
# 歌曲列表框
self.list_box = tk.Listbox(root, width=60, height=15)
self.list_box.pack(pady=10)
# 按钮区域
frame = ttk.Frame(root)
frame.pack(pady=5)
ttk.Button(frame, text="打开文件夹", command=self.load_music).grid(row=0, column=0, padx=5)
self.btn_play = ttk.Button(frame, text="播放", command=self.play_music)
self.btn_play.grid(row=0, column=1, padx=5)
ttk.Button(frame, text="停止", command=self.stop_music).grid(row=0, column=2, padx=5)
ttk.Button(frame, text="上一首", command=self.prev_music).grid(row=0, column=3, padx=5)
ttk.Button(frame, text="下一首", command=self.next_music).grid(row=0, column=4, padx=5)
# 加载文件夹内音乐
def load_music(self):
dir_path = filedialog.askdirectory()
if not dir_path:
return
self.music_list.clear()
self.list_box.delete(0, tk.END)
# 遍历音频文件
for file in os.listdir(dir_path):
if file.lower().endswith((".mp3", ".wav", ".flac")):
full_path = os.path.join(dir_path, file)
self.music_list.append(full_path)
self.list_box.insert(tk.END, file)
# 播放/暂停
def play_music(self):
if not self.music_list:
return
if self.is_pause:
pygame.mixer.music.unpause()
self.is_pause = False
self.btn_play.config(text="暂停")
else:
pygame.mixer.music.load(self.music_list[self.current_idx])
pygame.mixer.music.play()
self.btn_play.config(text="暂停")
self.is_pause = False
# 停止播放
def stop_music(self):
pygame.mixer.music.stop()
self.btn_play.config(text="播放")
self.is_pause = False
# 上一首
def prev_music(self):
if not self.music_list:
return
self.current_idx -= 1
if self.current_idx < 0:
self.current_idx = len(self.music_list) - 1
self.play_music()
# 下一首
def next_music(self):
if not self.music_list:
return
self.current_idx += 1
if self.current_idx >= len(self.music_list):
self.current_idx = 0
self.play_music()
if __name__ == "__main__":
window = tk.Tk()
app = MusicPlayer(window)
window.mainloop()
![屏幕截图 2026-06-07 234915]()
2025010153 范鹏展
推箱子地图
def save_pushbox_map_to_file():
# 地图元素说明:
# 0=空地 1=墙 2=玩家 3=箱子 4=目标点 5=箱子在目标点上 6=玩家在目标点上
map_data = [
[1, 1, 1, 1, 1, 1, 1],
[1, 0, 0, 0, 0, 0, 1],
[1, 0, 3, 0, 3, 0, 1],
[1, 0, 0, 2, 0, 0, 1],
[1, 0, 4, 0, 4, 0, 1],
[1, 0, 0, 0, 0, 0, 1],
[1, 1, 1, 1, 1, 1, 1]
]
# 写入文件
with open("pushbox_map.txt", "w", encoding="utf-8") as f:
for row in map_data:
f.write(",".join(map(str, row)) + "\n")
print("✅ 推箱子地图已保存到 pushbox_map.txt")
# --------------------------
# 2. 从文件加载地图(游戏运行时调用)
# --------------------------
def load_pushbox_map_from_file():
game_map = []
try:
with open("pushbox_map.txt", "r", encoding="utf-8") as f:
for line in f:
line = line.strip()
if not line:
continue
# 按逗号分割,转为整数列表
row = list(map(int, line.split(",")))
game_map.append(row)
print("✅ 推箱子地图加载成功!")
return game_map
except FileNotFoundError:
print("❌ 错误:pushbox_map.txt 不存在,请先运行 save_pushbox_map_to_file()")
return None
# --------------------------
# 3. 显示地图(调试用)
# --------------------------
def display_pushbox_map(game_map):
print("\n===== 推箱子地图 =====")
print("符号说明:■墙 □空地 P玩家 ●箱子 ○目标点 ◎箱子在目标点上 ★玩家在目标点上")
print()
for row in game_map:
for cell in row:
if cell == 0:
print("□", end=" ")
elif cell == 1:
print("■", end=" ")
elif cell == 2:
print("P", end=" ")
elif cell == 3:
print("●", end=" ")
elif cell == 4:
print("○", end=" ")
elif cell == 5:
print("◎", end=" ")
elif cell == 6:
print("★", end=" ")
else:
print("?", end=" ")
print()
# 主程序
if __name__ == "__main__":
save_pushbox_map_to_file()
game_map = load_pushbox_map_from_file()
if game_map:
display_pushbox_map(game_map)
![image]()
2025010154洪关瑞
给出学pythonset,cset和javaset的人
Pythonset = {'王海','李黎明','王铭年','李晗'}
Cset = {'朱佳','李黎明','王铭年','杨鹏'}
Javaset = {'王海','杨鹏','王铭年','罗明','李晗'}
only_python = Pythonset-Cset
print("只会python不会C的人:",only_python)
all_three = Pythonset & Cset & Javaset
print("三种语言都会的人:",all_three)

闫宸熙2025010157
import csv
csv_path = r"C:\Users\31969\Desktop\file_list.csv"
finance_data = {}
with open(csv_path, "r", encoding="utf-8") as f:
reader = csv.DictReader(f)
for row in reader:
quarter = row["季度"]
type_ = row["项目类型"]
amount = row["金额"]
note = row["备注"]
if quarter not in finance_data:
finance_data[quarter] = {"收入": [], "支出": []}
finance_data[quarter][type_].append(f"{note}:{amount}元")
print("==== 季度财务收支分类 ====")
for q, data in finance_data.items():
print(f"\n【{q}】")
print(" 收入项:")
for item in data["收入"]:
print(f" - {item}")
print(" 支出项:")
for item in data["支出"]:
print(f" - {item}")
2025010158陈文洁
书本44页12题
# 12题 初始列表 list1 = [54, 36, 75, 28, 50]
# (1) 在列表的尾部插入元素 52 list1.append(52) print("(1) 尾部插入52后:", list1)
# (2) 在元素 28 的前面插入元素 66 # 先找到元素28的索引,再用insert方法 idx = list1.index(28) list1.insert(idx, 66) print("(2) 在28前插入66后:", list1)
# (3) 删除并输出元素 28 val = list1.remove(28) # remove()无返回值,我们先找索引再pop idx = list1.index(28) removed_val = list1.pop(idx) print("(3) 删除并输出元素28,删除的值为:", removed_val) print(" 删除后列表:", list1)
# (4) 将列表按降序排序 list1.sort(reverse=True) print("(4) 降序排序后:", list1)
# (5) 清空整个列表 list1.clear() print("(5) 清空后:", list1)

2025010159 成哲煜
import re def extract_weather_info(weather_text): # 正则匹配时间:如 6月8日、今天、明天、周一、2026-06-08 time_pattern = r'(?:\d{4}[-年])?\d{1,2}[月-]\d{1,2}[日]|今天|明天|后天|周[一二三四五六日]' # 正则匹配天气关键词 weather_pattern = r'晴|多云|阴|小雨|中雨|大雨|暴雨|雷阵雨|小雪|中雪|大雪|雾|沙尘暴|大风' time_list = re.findall(time_pattern, weather_text) weather_list = re.findall(weather_pattern, weather_text) # 去重并整理结果 time_res = list(set(time_list)) if time_list else ["未识别到时间"] weather_res = list(set(weather_list)) if weather_list else ["未识别到天气"] return { "原文": weather_text, "提取到的时间": time_res, "提取到的天气状况": weather_res } # 测试示例 if __name__ == "__main__": # 示例天气预报文本 weather_str = "2026年6月8日周一,安康多云转小雨,明天阴天有大风,后天局部雷阵雨" result = extract_weather_info(weather_str) # 打印输出 for k, v in result.items(): print(f"{k}:{v}")
2025010160韩俊杰
import sounddevice as sd import soundfile as sf import keyboard import matplotlib.pyplot as plt import numpy as np import time # 基础参数 CHUNK = 1024 RATE = 44100 CHANNELS = 1 MAX_REC_SEC = 5 # 解决中文乱码 plt.rcParams['font.sans-serif'] = ['SimHei'] plt.rcParams['axes.unicode_minus'] = False print("按【任意按键】开始录音") keyboard.read_key() print(f"开始录音!最多录音 {MAX_REC_SEC} 秒,按【空格键】可提前结束") frames = [] start_time = time.time() end_time = start_time + MAX_REC_SEC stream = sd.InputStream(samplerate=RATE, channels=CHANNELS, blocksize=CHUNK) stream.start() # 【循环里只做录音+按键判断,绝对不放绘图代码】 while time.time() < end_time: data, _ = stream.read(CHUNK) frames.append(data) if keyboard.is_pressed('space'): print("\n检测到空格,手动结束录音") break stream.stop() stream.close() # 空数据保护 if len(frames) == 0: print("错误:未采集到音频") exit() print("录音完成!正在保存文件...") audio_data = np.concatenate(frames, axis=0) sf.write("my_recording.wav", audio_data, RATE) print("录音已保存") # 【绘图代码只在这里执行,全程只跑1次!】 print("生成波形图...") plt.figure(figsize=(10,4)) plt.plot(audio_data) plt.title("录音音频波形") plt.xlabel("采样点") plt.ylabel("音量幅值") plt.tight_layout() plt.show()
2025010161朱星月
音频
import asyncio
import edge_tts
async def text_to_audio(text: str, save_path: str, voice: str = "zh-CN-YunyangNeural"):
"""
:param text: 需要转语音的文字
:param save_path: 音频保存路径 xxx.mp3
:param voice: 音色:中文男/女,zh-CN-YunyangNeural男声,zh-CN-XiaoxiaoNeural女声
"""
communicate = edge_tts.Communicate(text, voice)
# save_sync是同步,移除await
communicate.save_sync(save_path)
if __name__ == "__main__":
# 冒号后缩进4空格写代码
content = "你好,生成中文语音"
asyncio.run(text_to_audio(content, "output.mp3"))
print("音频生成完成")

2025010162 刘奕桐
插入数字到一个列表中
lst = [1,2,4,5,7,10,25,152,52]
n = int(input())
pos = 0
for i in lst:
if i < n:
pos += 1
else:
break
lst.insert(pos,n)
print(lst)

2025010163 刘志杰
三个点到一条直线的和的最小值
# 三个点坐标
points = [(1, 2), (4, 6), (7, 1)]
# 记录最小距离总和,初始设成很大的数
min_total = 99999
# 记录最优直线的斜率k、截距b
best_k = 0
best_b = 0
# 循环遍历所有可能的斜率k
for k in range(-10, 11):
# 循环遍历所有可能的截距b
for b in range(-20, 21):
total = 0
# 计算三个点到直线y=kx+b的距离总和
for (x, y) in points:
# 点到直线距离公式
numerator = abs(k * x - y + b)
denominator = (k ** 2 + 1) ** 0.5
distance = numerator / denominator
total = total + distance
# 如果当前直线距离更小,更新最优值
if total < min_total:
min_total = total
best_k = k
best_b = b
print(f"最优直线:y = {best_k}x + {best_b}")
print(f"三个点到这条直线的距离总和最小值:{min_total:.2f}")

2025010164 李朋祖
# 学生-院系对应数据
student_department = {
"张三": "计算机学院",
"李四": "计算机学院",
"王五": "外国语学院",
"赵六": "机电工程学院",
"孙七": "外国语学院",
"周八": "计算机学院",
"吴九": "机电工程学院",
"郑十": "经济管理学院"
}
# 统计各院系人数
dept_count = {}
for dept in student_department.values():
dept_count[dept] = dept_count.get(dept, 0) + 1
# 展示所有院系,方便用户输入查询
print("===== 所有院系列表 =====")
for dept in dept_count.keys():
print(dept)
print("========================\n")
# 循环查询功能
while True:
# 输入要查询的院系
search_dept = input("请输入要查询的院系名称(输入0退出):")
# 退出程序
if search_dept == "0":
print("查询结束,程序退出!")
break
# 判断院系是否存在并输出人数
if search_dept in dept_count:
print(f"【{search_dept}】学生人数:{dept_count[search_dept]} 人\n")
else:
print("输入院系不存在,请核对名称后重新输入!\n")

2025010165 赵子月
矩阵到逆矩阵
def matrix_inverse(matrix):
"""
手动实现高斯-约旦消元法求方阵的逆矩阵
:param matrix: 输入方阵(二维列表)
:return: 逆矩阵(二维列表)
"""
n = len(matrix)
# 检查是否为方阵
for row in matrix:
if len(row) != n:
raise ValueError("必须输入方阵!")
# 构造增广矩阵 [A | E]
aug = [row[:] + [1 if i == j else 0 for j in range(n)] for i, row in enumerate(matrix)]
# 高斯消元
for col in range(n):
# 找主元
pivot_row = None
for r in range(col, n):
if abs(aug[r][col]) > 1e-10:
pivot_row = r
break
if pivot_row is None:
raise ValueError("矩阵不可逆!")
# 交换主元行
aug[col], aug[pivot_row] = aug[pivot_row], aug[col]
# 主元归一化
div = aug[col][col]
for j in range(col, 2 * n):
aug[col][j] /= div
# 消去其他行
for r in range(n):
if r != col and abs(aug[r][col]) > 1e-10:
factor = aug[r][col]
for j in range(col, 2 * n):
aug[r][j] -= factor * aug[col][j]
# 提取逆矩阵
inv_matrix = [row[n:] for row in aug]
return inv_matrix
# ==================== 测试代码 ====================
if __name__ == "__main__":
# 输入矩阵(手动输入)
A = [
[1, 2],
[3, 4]
]
try:
A_inv = matrix_inverse(A)
print("原矩阵:")
for row in A:
print(row)
print("\n逆矩阵:")
for row in A_inv:
print([round(x, 4) for x in row])
except ValueError as e:
print(e)
2025010166蒋子凡
# 导入随机模块
import random
# 生成5个1~100的随机整数
nums = []
for i in range(5):
n = random.randint(1, 100)
nums.append(n)
print("最初5个随机数:", nums)
# 再插入1个随机数
new_num = random.randint(1, 100)
nums.append(new_num)
print("插入一个随机数后:", nums)
# 从小到大排序
nums.sort()
print("从小到大排序:", nums)

2025010167杨书宇
正弦波重叠图
import numpy as np
import matplotlib.pyplot as plt
# 解决中文显示
plt.rcParams["font.family"] = ["SimHei"]
plt.rcParams["axes.unicode_minus"] = False
# 1.参数配置
t = np.linspace(0, 6*np.pi, 2000) # 时间区间
omega = 1 # 角频率
amp1, amp2 = 1, 1
phase_diff = np.pi/2 # 【修改此处:相位差值】
# 2.构造两路带相位差正弦
y1 = amp1 * np.sin(omega * t)
y2 = amp2 * np.sin(omega * t + phase_diff)
y_total = y1 + y2 # 波形叠加
# 3.绘图
plt.figure(figsize=(12,5))
plt.plot(t, y1, c="#1f77b4", label=f"波形1:$\\sin(\omega t)$", linewidth=1.6)
plt.plot(t, y2, c="#2ca02c", label=f"波形2:$\\sin(\omega t+{phase_diff:.2f})$", linewidth=1.6)
plt.plot(t, y_total, c="#d62728", label="叠加合成波形", linewidth=2.2)
plt.grid(alpha=0.3)
plt.legend(fontsize=11)
plt.title(f"正弦波相位差叠加(相位差={phase_diff:.3f}rad)")
plt.xlabel("t")
plt.ylabel("幅值")
plt.tight_layout()
plt.show()

2025010168 袁艺伦
import turtle
import time
# 设置窗口
win = turtle.Screen()
win.setup(800, 300)
win.title("小人左右往返走")
# 创建小人画笔
person = turtle.Turtle()
person.shape("turtle") # 小人造型
person.speed(0)
person.penup()
# 起始位置
x = -350
step = 5 # 移动步长
while True:
# 向右走
while x < 350:
person.goto(x, 0)
x += step
time.sleep(0.01)
# 向左走
while x > -350:
person.goto(x, 0)
x -= step
time.sleep(0.01)

闵子怡+2025010169+转置矩阵
# 1. 让用户输入矩阵的行数和列数
rows = int(input("请输入矩阵的行数: "))
cols = int(input("请输入矩阵的列数: "))
# 2. 接收用户输入的矩阵数据
matrix = []
print("请输入矩阵的每一行元素,用空格分隔:")
for i in range(rows):
row = list(map(int, input(f"第 {i+1} 行: ").split()))
matrix.append(row)
# 3. 计算转置矩阵
transposed_matrix = []
for j in range(cols):
new_row = []
for i in range(rows):
new_row.append(matrix[i][j])
transposed_matrix.append(new_row)
# 4. 输出原矩阵和转置矩阵
print("\n你输入的原矩阵是:")
for row in matrix:
print(row)
print("\n它的转置矩阵是:")
for row in transposed_matrix:
print(row)
![屏幕截图 2026-06-06 231447]()
2025010170张家祺
两组乒乓球队排列组合问题
group_jia = ['A', 'B', 'C', 'D']
group_yi = ['1', '2', '3', '4']
total = 0
for a in group_yi:
for b in group_yi:
if b == a:
continue
for c in group_yi:
if c == a or c == b:
continue
for d in group_yi:
if d == a or d == b or d == c:
continue
#规定A不能对3和4,B不能对1
if a not in ['3','4'] and b != '1':
total = total + 1
print('第',total,'种:A-',a,' B-',b,' C-',c,' D-',d)
print('总共有',total,'种排列方式')
2025010171陈宣汝
# 5条销售数据
data = [
["T恤", "2026.04.01", "张阳", 195],
["裤子", "2026.04.03", "李华", 178],
["鞋子", "2025.12.10", "王芳", 150],
["帽子", "2025.11.05", "张阳", 100],
["背包", "2026.04.08", "李华", 120]
]
# 按年份统计
year_total = {}
# 按销售员统计
seller_total = {}
for name, time, seller, money in data:
year = time[:4]
# 年份统计
if year in year_total:
year_total[year] += money
else:
year_total[year] = money
# 销售员统计
if seller in seller_total:
seller_total[seller] += money
else:
seller_total[seller] = money
print("按年份统计销售额:", year_total)
print("按销售员统计销售额:", seller_total)
2025010172 张景悦
超市商品表
# 商品字典 goods = {"苹果":8.5,"香蕉":5.0,"牛奶":4.5,"面包":6.0,"可乐":3.0,"薯片":7.5,"鸡蛋":1.2} # 购物清单 shop = [("苹果",2),("香蕉",1.5),("牛奶",1),("可乐",2),("鸡蛋",10)] # 价格表 print("=====商品价格=====") for k,v in goods.items():print(f"{k}:{v}元") # 结算 total=0 print("\n=====购物清单=====\n"+"-"*30) for n,m in shop: s=goods[n]*m total+=s print(f"{n}×{m} 单价{goods[n]} 小计{s:.1f}") print("-"*30+f"\n合计:{total:.1f}元")
杨云飞 2025010173
古代诗人时间段筛选出来
# 诗歌集数据:按时间段分类存储诗人及作品
poetry_collection = {
"唐代": {
"李白": ["《静夜思》", "《望庐山瀑布》"],
"杜甫": ["《春望》", "《登高》"],
"王维": ["《山居秋暝》", "《相思》"]
},
"宋代": {
"苏轼": ["《水调歌头·明月几时有》", "《念奴娇·赤壁怀古》"],
"李清照": ["《声声慢·寻寻觅觅》", "《如梦令·昨夜雨疏风骤》"],
"陆游": ["《示儿》", "《游山西村》"]
},
"现代": {
"徐志摩": ["《再别康桥》", "《偶然》"],
"海子": ["《面朝大海,春暖花开》", "《黑夜给了我黑色的眼睛》"],
"顾城": ["《一代人》", "《远和近》"]
}
}
def get_poets_by_period(period):
"""根据时间段筛选诗人"""
period = period.strip()
if period in poetry_collection:
poets = list(poetry_collection[period].keys()) # 提取该时间段的所有诗人
return poets
else:
return None # 未找到该时间段
# 示例使用
if __name__ == "__main__":
# 用户输入时间段
user_period = input("请输入要查询的时间段(如唐代、宋代):")
poets = get_poets_by_period(user_period)
if poets:
print(f"\n{user_period}的诗人有:")
for poet in poets:
print(f"- {poet}")
else:
print(f"\n未收录{user_period}的诗人信息")

2025010174 刘研
安康学院院系专业(树枝版)
# 安康学院院系专业数据
data = {
"文学与传媒学院": ["汉语言文学", "秘书学", "网络与新媒体"],
"马克思主义学院": ["思想政治教育", "社会工作"],
"教育学院": ["学前教育", "小学教育"],
"外语学院": ["英语", "商务英语"],
"数学与统计学院": ["数学与应用数学", "统计学"],
"电子与信息工程学院": ["计算机科学与技术", "电子信息工程", "数字媒体技术", "应用物理学", "信息管理与信息系统", "物联网工程", "电子商务"],
"化学与环境学院": ["应用化学", "化学工程与工艺", "制药工程", "化妆品技术与工程", "环境生态工程"],
"现代农业与生物科技学院": ["农学", "园林", "食品科学与工程", "生物技术", "茶学"],
"艺术学院": ["美术学", "音乐学", "视觉传达设计"],
"经济与管理学院": ["财务管理", "会计学", "工程管理", "金融工程", "工程造价", "旅游管理"],
"体育学院": ["体育教育"],
"医学院": ["护理学", "康复治疗学"]
}
# 打印标题
print("安康学院院系专业(树枝版)")
print("------------------------")
# 遍历打印学院和专业(树叶分枝效果)
for college, majors in data.items():
print("└──", college)
for major in majors:
print(" └──", major)
# 统计总数
print("\n------------------------")
print("学院总数:", len(data), "个")
print("专业总数:", sum(len(m) for m in data.values()), "个")


2025010175 孙兰妮
利用图片的像素点求平均颜色
from PIL import Image
def get_average_color(img_path):
img = Image.open(img_path)
img = img.convert("RGB")
pixels = list(img.getdata())
print(pixels)
r_sum = 0
g_sum = 0
b_sum = 0
for r, g, b in pixels:
r_sum += r
g_sum += g
b_sum += b
count = len(pixels)
avg_r = r_sum // count
avg_g = g_sum // count
avg_b = b_sum // count
return avg_r, avg_g, avg_b
r, g, b = get_average_color("我的图.jpg")
print("图片平均颜色 RGB:",r, g, b)











浙公网安备 33010602011771号