think python(PDF download)

c#小王子 c#小王子 2021-05-12 1188 Python


think  python(PDF download)



Preface


The strange history of this book


In January 1999 I was preparing to teach an introductory programming class in Java.Ihad taught it three times and I was getting frustrated. The failure rate in the class was too high and, even for students who succeeded, the overall level of achievement was too low.


Oneof the problems I saw was the books. They were toobig, with toomuchunnecessary detail about Java,and not enough high-levelguidance about how to program. And they all suffered from the trap door effect: they would start out easy, proceed gradually, and then somewhere around Chapter 5 the bottom would fall out. The students would get too much new material, too fast,and I would spend the rest of the semester picking up the pieces.

Two weeks before the first day of classes,I decided to write my own book. My goals were:


·Keep it short. It is betterfor students to read 10 pages than not read 50 pages.


·Be careful with vocabulary. I tried to minimize the jargon and define each term a fist use.·Build gradually.To avoid trap doors, I took the most difficult topics and split them into a series of small steps.


·Focus on programming.not the programming language.Iincluded the minimumuseful subset of Java and left out the rest.


I needed a title, so on a whim I chose How to Think Like a Computer Scientist.


My first version was rough, but it worked. Students did the reading, and they understood enough that I could spend class time on the hard topics, the interesting topics and (most important)letting the students practice.


Ireleased the book under the GNU FreeDocumentation License,which allows users to copy,modify, and distribute the book.


What happened nextis thecoolpart. Jeff Elkner, a high school teacherin Virginia,adopted my book and translated it into Python.He sent me acopy of his translation,and Ihad the unusual experience of learning Python by reading my own book.


Jeff and I revised the book, incorporated a case study by Chris Meyers, and in 2001 we released HowtoThink Like a Computer Sdentist:Learning with Python, also under the GNU Free Doc- umentation License. As Green Tea Press, I published the book and started selling hard copies through Amazon.com and college book stores. Other books from Green Tea Press are available at greenteapress. com.


In 2003 I started teaching at Olin College andI got to teach Python for the first time. The contrast with Java was striking. Students struggled less,learmed more, worked on more interesting projects, and generally had a lot more fun.


Over the last five years I have continued to develop the book,correcting errors,improving some of the examples and adding material, especially exercises.In2008 Istarted workona majorrevision— at the same time,I was contacted by an editor at Cambridge University Press who was interested in publishing the next edition. Good timing!


The result is this book,now with the less grandiose title Think Python. Some of the changes are:


·I added a section about debugging at the end of each chapter. These sections present general techniques for finding and avoiding bugs.and warnings about Python pifalls.


·I removed the material in the last few chapters about the implementation of lists and trees.I still love those topics, but I thought they were incongruent with the rest of the book.


·I added more exercises,ranging from short tests of understanding to afew substantialprojects.


·I added a series of case studies—longer examples with exercises, solutions, and discussion. Some of them are based on Swampy.a suite of Pythonprograms I wrote for use in my classes. Swampy,code examples, and some solutions are available from thinkpython.cam.


·I expanded the discussion of program development plans and basic design patterns.· The use of Python is more idiomatic. The book is still about programming, not Python, but now I think the book gets more leverage from the language.


I hope you enjoy working with this book,and that it helps you learn to program and think,at least a little bit, like a computer scientist.


Allen B. Downey

Needham MA


Allen Downey is an Associate Professor of Computer Science at the Franklin W.Olin College of Engineering.


Chapter 1


The way of the program


The goal of this book is to teach you to think like a computer scientist. This way of thinking com- bines some of the best features of mathematics, engineering, and natural science. Like mathemati- cians, computer scientists use formal languages to denote ideas(specifically computations). Like engineers, they design things,assembling components into systems and evaluating tradeoffs among alternatives. Like scientists, they observe the behavior of complex systems, form hypotheses, and test predictions.


The single most important skill for a computer scientist is problem solving. Problem solving means the ability to formulate problems, think creatively about solutions,andexpress asolution clearly and accurately. As it turns out, the process of leaming to program is an excellent opportunity to practice problem-solving skills. That's why this chapter is called,"The way of the program."


On one level, you will be learning to program,a useful skill by itself. On another level,you will use programming as a means to an end. As we go along,that end will become clearer.


1.1 The Python programming language


The programming language you will learn is Python. Python is an example of ahigh-level language; other high-level languages you might have heard of are C, C++,Perl, and Java.


There are also low-level languages, sometimes referred to as"machine languages" or"assembly languages."Loosely speaking, computers can only execute programs written in low-level languages. So programs written in a high-level language have to be processed before they can run. This extra processing takes some time, which is a small disadvantage of high-level languages.


The advantages are enormous. First, it is much easierto program in a high-levellanguage. Programs written in a high-level language take less time to write,they are shorter and easier to read,and they are more likely to be correct. Second, high-level languages are portable, meaning that they can run on different kinds of computers with few or no modifications. Low-level programs can run on only one kind of computer and have to be rewritten to run on another.


Due to these advantages,almost all programs are written in high-level languages. Low-level lan- guages are used only for a few specialized applications.


Two kinds of programs process high-level languages into low-levellanguages: interpreters and compilers. An interpreter reads a high-level program and executesit.meaning that it does what the program says. It processes the program a little at a time,alternately reading lines and performing Computations.



Acompiler reads the program and translates it completely before the program starts running.In this context. the high-level program is called the source code.and the translated program is called the object code or the executable. Once a program is compiled,you can execute it repeatedly without further translation.



Python is considered an interpreted language because Python programs are executed by an inter- preter. There are two ways to use the interpreter: interactive mode and script mode.In interactive mode, you type Python programs and the interpreter prints the result:


>>> 1 +1
2


The chevron,>>>,is the prompt the interpreteruses to indicate that it is ready.If you type 1 + i, the interpreter replies 2.


Altematively, you can store code in a file and use the interpreter to execute the contents of the file, which is called a script. By convention, Python scripts have names that end with .py.


To execute the script,you have to tell the interpreter the name of the file. In a UNIX command window, you would type python dinsdale.py. In other development environments, the details of executing scripts are different. You can find instructions for yourenvironment at the Python Website python.org.


Working ininteractive mode is convenient for testing small pieces ofcode because you can type and execute them immediately. But for anything more than a few lines,you should save your code as a script so you can modify and execute it in the future.


1.2 What is a program?


A program is a sequence of instructions that specifies how to perform a computation. The compu- tation might be something mathematical,such as solving a system of equations or finding the roots of a polynomial, but it can also be a symbolic computation,such as searching and replacing text in a document or (strangely enough)compiling a program.


The details look different in different languages, but a few basic instructions appear in just about every language:


input: Get data from the keyboard, a file,or some other device.



【download link】

link:https://pan.baidu.com/s/1pHceWlnrA2DBwZWgZXQzYQ

Extraction code:38mp


相关文章


R基础及应用-大数据分析(高清PDF 下载)

为了更好地适应新形势,满足读者对大数据分析处理学习的迫切需要,我们推出了《大数据分析 ∶ R基础及应用》一书 ,力求使读者能够从中了解大数据

《R数据科学》高清中/英文版PDF+源代码

读完本书后,你将掌握R语言的精华,并能够熟练使用多种工具来解决各种数据科学难题。

用Python写网络爬虫(高清PDF 下载)

网络爬虫是一个自动提取网页的程序,它为搜索引擎从万维网上下载网页,是搜索引擎的重要组成。传统爬虫从一个或若干初始网页的URL开始, 获得初始

用Python进行自然语言处理(高清PDF 下载)

通过它,你将学到如何写能处理大量非结构化文本的 Python 程序。你将获得有丰富标注的涵盖语言学各种数据结构的数据集,而且你将学到分析书面

简明python教程(高清PDF下载)

本书可以作为Python编程语言的一本指南或者教程。它主要是为新手而设计,不过对于有经验的程序员来说,它同样有用。

集体智慧编程-python算法应用(高清PDF 下载)

本书以机器学习与计算统计为主题背景,专门讲t述如何挖掘和分析 Web,上的数据和资源,如何分析用户体验、市场营销、个人品味等诸多信息,并得出

编程小白的第一本+python+入门书(高清PDF下载)

为了能让更多的编程小自轻松地入门编程,我把高效学习法结合 Pvthon 中的核心知识,写成了这本书。随意翻上几页,你就会发现这本书和其他编程

笨办法学.Python.(第三版)(高清PDF下载)

本书结构非常简单,其实就是 52 个习题。其中 26 个覆盖了输入输出、变量、以及函数三个课题,另外 26个覆盖了一些比较高级的话题,如条件

visualizing data(PDF download)

In this book,I wanted to offer something for people who want to get

think python(PDF download)

think python(How to Think like a Computer Scientist)

Rapid GUI Programming with Python and Qt download

This book is specifically about PyQt4, the Python bindings for the Qt

Python源码剖析(高清PDF 下载)

本书以CPython为研究对象,在C代码一级,深入细致地剖析了Python的实现。本书不仅包括了对大量Python内置对象的剖析,更将大量的

Python学习手册(第4版)(中文版高清PDF 下载)

本书是学习Python编程语言的入门书籍。Python是一种很流行的开源编程语言,可以在各种领域中用于编写独立的程序和脚本。Python免费

Python算法教程_中文版(高清PDF下载)

本书用 Python 语言来讲解算法的分析和设计。本书主要关注经典的算法,但同时会为读者理解基本算法问题和解决问题打下很好的基础。全书共 1

Python数据分析基础(高清PDF下载)

本书面向的读者是那些经常使用电子表格软件进行数据处理,但从未写过一行代码的人。前几章会教你设置 Python 运行环境,告诉你计算机是如何看


文章热度: 166291
文章数量: 333
推荐阅读

FlashFXP绿色版网盘下载,附激活教程 1924

FlashFxp百度网盘下载链接:https://pan.baidu.com/s/1MBQ5gkZY1TCFY8A7fnZCfQ。FlashFxp是功能强大的FTP工具

Adobe Fireworks CS6 Ansifa绿色精简版网盘下载 1665

firework可以制作精美或是可以闪瞎眼的gif,这在广告领域是需要常用的,还有firework制作下logo,一些原创的图片还是很便捷的,而且fireworks用法简单,配合dw在做网站这一块往往会发挥出很强大的效果。百度网盘下载链接:https://pan.baidu.com/s/1fzIZszfy8VX6VzQBM_bdZQ

navicat for mysql中文绿色版网盘下载 1699

Navicat for Mysql是用于Mysql数据库管理的一款图形化管理软件,非常的便捷和好用,可以方便的增删改查数据库、数据表、字段、支持mysql命令,视图等等。百度网盘下载链接:https://pan.baidu.com/s/1T_tlgxzdQLtDr9TzptoWQw 提取码:y2yq

火车头采集器(旗舰版)绿色版网盘下载 1793

火车头采集器是站长常用的工具,相比于八爪鱼,简洁好用,易于配置。火车头能够轻松的抓取网页内容,并通过自带的工具对内容进行处理。站长圈想要做网站,火车头采集器是必不可少的。百度网盘链接:https://pan.baidu.com/s/1u8wUqS901HgOmucMBBOvEA

Photoshop(CS-2015-2023)绿色中文版软件下载 1916

安装文件清单(共46G)包含Window和Mac OS各个版本的安装包,从cs到cc,从绿色版到破解版,从安装文件激活工具,应有尽有,一次性打包。 Photoshop CC绿色精简版 Photoshop CS6 Mac版 Photoshop CC 2015 32位 Photoshop CC 2015 64位 Photoshop CC 2015 MAC版 Photoshop CC 2017 64位 Adobe Photoshop CC 2018 Adobe_Photoshop_CC_2018 Photoshop CC 2018 Win32 Photoshop CC 2018 Win64

知之

知之平台是全球领先的知识付费平台。提供各个领域的项目实战经验分享,提供优质的行业解决方案信息,来帮助您的工作和学习

使用指南 建议意见 用户协议 友情链接 隐私政策 Powered by NOOU ©2020 知之