主题笔记:MIT公开课<计算机科学及编程导论>

课程目标

GOALS(课程目标):

  • basic tools of computational thinking to write small scale programs
    学会用计算思维的基本工具来编写小规模程序

  • the ability to use a vocabulary of computational tools in order to be able to understand programs written by others
    有能力使用计算工具的语言用来理解别人编写的程序

  • the fundamental both capabilities and limitations of computations and the costs associated with them
    了解计算机的能力和局限以及他们相关的代价

  • to map scientific problems into a computational frame
    学会把科学问题转换进计算机的框架之内

  • think like a computer scientist and what is computation
    像计算机科学家一样思考并且知道计算机是什么


这个文集里的系列笔记主要记录什么?

这个计算机科学及编程导论课的编号里含有101。什么意思呢?意思是面向大学一、二年级的“菜鸟们”的入门课程。课程里使用的编程语言Python只是讲了基础知识。而关于需要学习的Python知识,这些还远远不够,所以需要单独买教材来学,比如《Python核心编程》。

然后,这个笔记会抛掉那些相对来说不重要的内容,比如关于Python的知识,主要记录一些重要的与计算机科学和编程有关的思想


那么就进入正题了!

一个重点:about computational complexity

Identify the different classes of algorithms, what their costs are and how you can map problems into the most efficient class to do the computation

在这门导论课里,重点介绍的算法的种类是迭代和递归(iteration and recursion)。

具体一点就是什么是迭代和递归?写成代码的样子是什么?各自的特别和好处是什么?什么问题适合用他们解决且用起来效率最高?这些后面会有笔记。


一个细节:

流程图(Flow Chart),在实际写代码前做的工作。


一种代码的风格(style):defensive programing

先一个例子:

ans = 0
if x > 0:
   whlie ans*ans < x:
        ans = ans + 1
   if ans*ans !=x:
        print(x, "is not a perfect square")
   else: 
        print(ans)
else: 
   print(x,"is a negative number") 

This piece of code shows the basic idea which assume that

  • A) if you're getting input from a user, they won't necessarily give you the input you're asked for, so if you ask for a postive number, don't count on them giving you one,

  • B) if you're using a piece of program who is not perfect, there could be mistakes in that program, so you write your program in the assumption that, not only might the user make a mistake, other parts of your program might also make a mistake, and you just put in lots of different tests(showed on the code above) under the assumption that you'd rather catch that something has gone wrong than have it gone wrong and not know it.

余下的细节见文集里的各个主题笔记

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容