计算思维与计算机导论,计算思维与计算机导论_董荣胜.pdf

计算思维与计算机导论_董荣胜.pdf

36  4 Vol.36 No.4

2009 4 Computer Science Apr.2009

(桂林电子科技大学计算机与控制学院 桂林541004)

计算思维是目前国际计算机界广为关注的一个重要概念。 2008 年6 月, A CM 提交的《CS2001 中期审查》 报

(草案)将“计算思维”与“计算机导论”课程绑定在 一起, 明确要求“计算机导论”课程讲授计算思维的本质。 根据

ACM 的要求, 分别介绍了以“计算思维”和“ 学科思想与方法”为基础的两类“计算机导论”课程, 给出了两类“计算机导

论”课程的讲授提纲, 指出了它们的不同点以及课程讲授本质上的一致性。 最后认为, 两类课程各有所长, 值得相互吸

收和借鉴, 同时, 也有助于以“计算思维能力”培养为核心的“计算机导论”课程的教学改革, 并为计算学科其他课程的

教学提供 一种可以借鉴的改革模式。

计算学科, 计算思维, 计算机导论, 计算机科学与技术方法论

G642

Computational Thinking and Introduction to Computer Science

DONG Ron -shen

(School of C om puter and Control, Guilin University of Electronic T echnolo y, Guilin 541004, China)

Abstract Computational thinkin is becomin an important concept widely concerned over the field of computer science

today.CS 200 1 Interim Review (draft), submit ted by A CM in June 2008, proposed that the introductory course should

capture the essence of computational thinkin .Accordin to the report, this paper respectively described tw o kinds of

introductory courses:one is based on computational thinkin , and the other based on discipline principles and methodo-

lo ies;it also provided their syllabuses and pointed out their differences and consistency in essence.Finally we thou ht

the stren ths of the tw o kinds of introductory courses are different but complementary, and the com plementarity can al-

so contribute to the teachin reform of the course “ Introduction to computer science” with a core of competency trainin

of computational thinkin , w hich w ill provide a ood example for the teachin of other courses of computer science.

Keywords Computer science, Computation

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我们可以用 Python 字典实现这个图书管理系统。首先,我们需要定义三个字典,分别存储图书信息、借阅信息和学生信息。代码如下: ``` books = { '1001': {'书名': '计算机科学导论', '出版社': '高等教育出版社', '作者': '董荣胜', '价格': 39, '库存': 5}, '1002': {'书名': 'Python程序设计', '出版社': '电子工业出版社', '作者': '胡凤国', '价格': 68, '库存': 8}, '1003': {'书名': '算法导论', '出版社': '机械工业出版社', '作者': 'Thomas', '价格': 128, '库存': 1} } borrow = { '10001': {'1001': {'借阅日期': '20230319', '还书日期': '20230420'}}, '10002': {'1003': {'借阅日期': '20230201', '还书日期': ''}} } students = { '10001': {'姓名': '张强', '性别': '男', '班级': '自动化2101'}, '10002': {'姓名': '李琳', '性别': '女', '班级': '临床2202'} } ``` 接下来,我们需要实现各个功能。第一步是将表1和表3的信息分别保存到文件。代码如下: ``` import json # 将books保存到文件1中 with open('books.json', 'w') as f: json.dump(books, f) # 将students保存到文件2中 with open('students.json', 'w') as f: json.dump(students, f) ``` 第二步是从文件中读出图书信息和学生信息。代码如下: ``` # 从文件1中读出books with open('books.json', 'r') as f: books = json.load(f) # 从文件2中读出students with open('students.json', 'r') as f: students = json.load(f) ``` 第三步是实现借阅功能。代码如下: ``` def borrow_book(student_id, book_id): if student_id in borrow and len(borrow[student_id]) >= 5: return '借阅失败,每个学生最多借阅5本书' if book_id not in books or books[book_id]['库存'] < 1: return '借阅失败,该书已被借完' borrow_date = input('请输入借阅日期(格式为YYYYMMDD):') borrow[student_id][book_id] = {'借阅日期': borrow_date, '还书日期': ''} books[book_id]['库存'] -= 1 with open('borrow.json', 'w') as f: json.dump(borrow, f) with open('books.json', 'w') as f: json.dump(books, f) return '借阅成功' ``` 第四步是实现还书功能。代码如下: ``` def return_book(student_id, book_id): if student_id not in borrow or book_id not in borrow[student_id]: return '还书失败,该学生没有借阅该书' return_date = input('请输入还书日期(格式为YYYYMMDD):') borrow[student_id][book_id]['还书日期'] = return_date books[book_id]['库存'] += 1 with open('borrow.json', 'w') as f: json.dump(borrow, f) with open('books.json', 'w') as f: json.dump(books, f) return '还书成功' ``` 第五步是输入某学生姓名,可以查询该生的借阅图书信息。代码如下: ``` def search_borrow(student_name): student_id = '' for id, info in students.items(): if info['姓名'] == student_name: student_id = id break if not student_id: return '查询失败,该学生不存在' if student_id not in borrow: return '该学生没有借阅任何书籍' result = [] for book_id, info in borrow[student_id].items(): book_info = books[book_id].copy() book_info.update(info) result.append(book_info) return result ``` 第六步是输入某书号,可以查询借阅该书的学生信息。代码如下: ``` def search_student(book_id): if book_id not in borrow: return '该书没有被借阅' result = [] for student_id, info in borrow.items(): if book_id in info: student_info = students[student_id].copy() student_info.update(info[book_id]) result.append(student_info) return result ``` 第七步是输入出版社的名称,可以统计图书馆中该出版社的图书藏书量。代码如下: ``` def count_publisher(publisher_name): count = 0 for book_id, info in books.items(): if info['出版社'] == publisher_name: count += info['库存'] return count ``` 以上就是用 Python 字典实现图书管理系统的全部代码。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值