摘要:
4.4Functions: The Foundation of Structured Programming 函数:结构化编程的基础 Functions provide an effective way to package and re-use program code, as already explained inSection 2.3. For example, suppose we find that we often want to read text from an HTML file. This involves several steps: opening the file, 阅读全文
摘要:
4.3Questions of Style 关于风格 Programming is as much an art as a science(编程作为一门像艺术一样的科学). The undisputed "bible" of programming, a 2,500 page multi-volume work by Donald Knuth, is calledThe Art of Computer Programming. Many books have been written onLiterate Programming, recognizing that huma 阅读全文
摘要:
4.2Sequences序列 So far, we have seen two kinds of sequence object: strings and lists. Another kind of sequence is called atuple. Tuples are formed with the comma operator, and typically enclosed using parentheses. We've actually seen them in the previous chapters, and sometimes referred to them a 阅读全文
摘要:
Chapter 4 Writing Structured Programs编写结构化程序 By now you will have a sense of the capabilities of the Python programming language for processing natural language. However, if you're new to Python or to programming, you may still be wrestling with(努力对付) Python and not feel like you are in full con 阅读全文
摘要:
3.12Exercises 练习 ☼ Define a string s = 'colorless'. Write a Python statement that changes this to "colourless" using only the slice and concatenation operations. ☼ We can use the slice notation to remove morphological endings on words. For example, 'dogs'[:-1] removes the l 阅读全文
摘要:
3.11Further Reading深入阅读 Extra materials for this chapter are posted at http://www.nltk.org/ , including links to freely available resources on the Web. Remember to consult the Python reference materials at http://docs.python.org/ . (For example, this documentation covers “universal newline support,” 阅读全文
摘要:
3.10Summary小结 • In this book we view a text as a list of words. A “raw text” is a potentially long string containing words and whitespace formatting, and is how we typically store and visualize a text. • A string is specified in Python using single or double quotes:'Monty Python', "Mont 阅读全文
摘要:
偶然看到一道趣味题,将一个正整数倒置过来,例如,将1234变成4321。如果采用C的话,使用do..while语句来做,只要temp不为0,每执行一次,rebmun用来存原整数的最右边的数字并乘以10。代码如下:#include<stdio.h>voidmain(){intnumber=0;intrebmun=0;inttemp=0;printf("\nEnteranumber:");scanf("%d",&number);temp=number;do{rebmun=10*rebmun+temp%10;temp=temp/10;}wh 阅读全文
摘要:
关于该部分的项目描述请见Project2 Percolation in Grids 网格渗透 测试的场景要求如下:· set n=75 · consider values of p from 0 to 1 in increments of 0.05 (or smaller) · for each value of p, generate 10 random grids and record for each algorithm the average running time on the ten grids 可是我在编写该部分的测试代码时,遇到了些麻烦,一开始还 阅读全文
摘要:
此实验来自于part1中的具体要求:Next, consider grid sizes n = 10, 25, 50, and 75 and determine the percolation probabilities (you already know it for n=25). One way to visualize the performance for the different values of n is to make the same curve as above and show all three in one plot. Discuss how the size o. 阅读全文