- 博客(9)
- 收藏
- 关注
转载 欢迎使用CSDN-markdown编辑器
append 和extend都只需要一个参数,并且自动添加到数组末尾,如果需要添加多个,可用数组嵌套,但是 append是将嵌套后的数组作为一个对象, extend是将嵌套的数组内容作为多个对象,添加到原数组中 作为编程0基础的小白,觉得有必要自己再梳理一遍: 1.append()方法是指在列表末尾增加一个数据项。 例如:在students列表末尾增加”Gavin”项。
2017-03-21 23:26:08 248
原创 Lecture 7 - Debugging
Lecture 7 - Debugging1. Testing and DebuggingWhat is Testing and Debugging Testing method: Ways of trying code on examples to determine if running correctly Debugging methods W
2017-03-07 17:57:36 345
原创 Lecture 6 - Objects
Lecture 6 - Objects1. TupleCompound data types:TuplesLists DictionariesTuple:t1 = (1, ‘two’, 3) print(t1)example:## divisorsdef findDivisors(n1, n2): """assumes that n1 and n2 are positi
2017-03-06 17:35:07 277
转载 Python 列表(list)、字典(dict)、字符串(string)常用基本操作小结
[python] view plain copy创建列表 sample_list = ['a',1,('a','b')] Python 列表操作 sample_list = ['a','b',0,1,3] 得到列表中的某一个值 value_start = sample_list[0] end_value = sam
2017-03-06 16:18:45 437
转载 Iterative Method / Recursive Method
Iterative Method「疊代法」。以確定的部分作為起始點,循序漸進推演,最後求得答案。「疊代法」也會有無窮無盡的情況,例如以試除法建立質數,質數是越建越多;又例如微積分所學的牛頓法,遇到曲線時,小數位數是越算越多。寫程式時經常以迴圈來實作。因為迴圈事實上也可以用遞迴來完成,所以讀者也可以利用遞迴來實作,只不過我想大家沒必要這麼無聊。Recursive Method
2017-03-06 16:14:57 327
原创 Lecture 5 - Recursion
Lecture 5 - Recursion1. ITERATIVE ALGORITHMSconcept: Looping constructs (e.g. while or for loops) lead naturally to iterative algorithmsdef iterMul(a, b): result = 0 while b > 0
2017-03-06 15:52:24 271
原创 Lecture 1&2 - Introduction to Computation
Introduction to ComputationIntroductionBasics of Computation - 课程目标+计算机能做什么:储存和计算+快速计算能力+还需要什么(如算法)+有哪些限制 eg: What is the difference between an Algorithm and a Program? Answer: An algorithm is a con
2017-03-02 11:19:53 319
原创 Lecture 4 - Functions
Lecture 4 - Functions1. Function syntaxSyntax def <function name> (<formal parameters>): <function body>tipsIf the output can be either an int or a float, select num, which isn’t a real Python type
2017-03-01 15:32:06 221
原创 Lecture 3 - Simple Algorithms
Lecture 3 - Simple AlgorithmsIterationGuess and Check AlgorithmsFLOATING POINT ACCURACYAPPROXIMATION METHODSBISECTION SEARCHInterationx = 3ans = 0itersLeft = xwhile (itersLeft != 0): ans =
2017-02-27 17:37:47 297
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人