WEEK1-4: from L1(intro) to L7(debegging)

6.00.1x Introduction to Computer Science and Programming Using Python (EDX)

WEEK1-4笔记: from L1(intro) to L7(debegging)


WEEK1-LECTURE1-Introduction to Computer Science

1. An Algorithm VS a Program: An algorithm is a conceptual idea, a program is a concrete instantiation of an algorithm.

2. A computational mode of thinking means that everything can be viewed as a math problem involving numbers and formulas. 

3. The two things every computer can do are: Perform calculations , Remember the results 

4. Declarative knowledge refers to statements of fact. Imperative knowledge refers to 'how to' methods.

5. A fixed program computer VS a stored program computer

6. A program counter points the computer to the next instruction to execute in the program.

7. The computer executes the instructions mostly in a linear sequence, except sometimes it jumps to a different place in the sequence. 

8. Syntax – which strings of characters and symbols are well-­‐formed; Static semantics – which syntactically valid strings have a meaning; Semantics – what is the meaning associated with a syntactically correct string of symbols with no static semantic errors


WEEK1-LECTURE2-Core Elements of Programs

1. Program (or script) is a sequence of definitions and commandsCommand (or statement) instructs interpreter to do something
2. Each object has a type that defines the kinds of things programs can do to it; Objects and operators can be combined to form expressions, each of which denotes an object of some type

2.1 Scalar objects: int, float, bool
1) Operators on ints and floats: +, -, *, /, //, %, **; Comparison operators on ints and floats: >, >=, <, <=, ==, != (Any string is always bigger than any int. )
2) Operators on bools: and, or, not
2.2 Non-scalar objects: str

>>> 3 * 'a'
'aaa'
>>> 'abc'[0] #indexing
'a'
>>> 'abc'[-1]
'c'
>>> 'abc'[1:3] #slicing
'bc'

3. The Python 'None' keyword: In Python, the keyword None is frequently used to represent the absence of a value. None is the only value in Python of type NoneType.
4. The Python 'in' operator: element in coll, element not in coll = not (element in coll)
5. Advanced String Slicing

>>> s = 'Python is Fun!'
>>> s[1:12:2] #s[i:j:k] This gives a slice of the string s from index i to index j-1, with step size k.
'yhni u'
>>> s[1:12:3]
'yoiF'
>>> s[::2]
'Pto sFn'

6. print, raw_input(), type()

7. Branching structures: conditionals e.g., if/elif/else


WEEK2-LECTURE3-Simple Algorithms

1. Looping structures, e.g., while

2. +=, -=, *=, /=; range(start, stop, stepSize)

3. Guess and Check Algorithms: Exhaustive enumeration, Bisection search, Newton-Raphson (for root finding)
(Newton proved a theorem that implies that if a value, call it guess, is an approximation to a root of a polynomial, then guess – p(guess)/p’(guess), where the first derivative of p, is a better approximation. ---from textbook)

4. Decimal number VS Binary number: 302 = 3*10**2 + 0*10**1 + 2*10**0; 10011 = 1*2**4 + 0*2**3 + 0*2**2 + 1*2**1 + 1*2**0 (16 + 2 + 1 = 19);

5. Printing on the same line: add a comma after the print statement


WEEK2-LECTURE4-Functions

1. def, return

2. str.lower(), upper(), isupper(), islower(), capitalize(), swapcase(), index(), find(), replace()


WEEK3-LECTURE5-Recursion(★)

1. The Euclidean algorithm can be used to find the greatest common divisor: If b = 0, then the answer is a; Otherwise, gcd(a, b) is the same as gcd(b, a % b)  example
2. Factorial, Towers of Hanoi, Fibonacci

3. 'divide and conquer' algorithm: solve a hard problem by breaking it into a set of sub-problems

4. Global variables(Use with care!!)

5. import; open(), 'w', 'r', 'a'; read(), readline(), readlines(), write(), writeLines(), close()


WEEK3-LECTURE6-Objects

1. Compound data types: tuples, lists(mutable), dictionaries(mutable)

2. is; 

3. list.sort(), insert(), remove(), append(), pop(), count(), extend(), reverse(); clone

4. str.rfind(), rindex(), rstrip(), split()

5. (dictionaries).has_key(), values(), keys(), get()


WEEK4-LECTURE7-Debugging

1. Black-box testing is a method of software testing that tests the functionality of an application. Recall from the lecture that a way to think about black-box testing is to look at both: The possible paths through the specification. The possible boundary cases.

2. Glass-box test suite is path-complete

3. PS4收获:1. \n 空一行,2. function可以既不print也不return




主要就是PPT,如果期末考试前觉得还不错的话,期末考试前的笔记也这样。。



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值