计算机班级有七个学生,参加元旦晚会。需要在七个人中随机抽取两位同学,这七个同学用列表来存储student_pool = ['武大','牛二','张三','李四','王五','赵六','张三丰']。定义函数choose_student(*pool) Python代码
时间: 2023-06-05 21:05:43 浏览: 87
def choose_student(*pool):
import random
return random.sample(pool, 2)
student_pool = ['武大','牛二','张三','李四','王五','赵六','张三丰']
result = choose_student(*student_pool)
print("选中的同学分别是:", result[0], "和", result[1])
阅读全文