标签:
***** WEEK-01 *****
5. Programming Language:
Each programming language provides a set of primitiveoperations.
Each programming language provides mechanisms for combining primitives to form more complex, but legal, expressions.
Each programming language provides mechanisms for deducingmeanings or values associated with computations or expressions.
6.
7.
There‘s one other cool thing you can do with string slicing. You can add a third parameter,
k
, like this:s[i:j:k]
. This gives a slice of the strings
from indexi
to indexj-1
, with step sizek
. Check out the following examples:
>>> s = ‘Python is Fun!‘
>>> s[1:12:2]
‘yhni u‘
>>> s[1:12:3]
‘yoiF‘
>>> s[::2]
‘Pto sFn‘
The last example is similar to the example
s[:]
. Withs[::2]
, we‘re asking for the full strings
(from index 0 through 13), with a step size of 2 - so we end up with every other character ins
. Pretty cool!
7. 关于函数 raw_input() 的使用。8. 在 # 的后面写注释。9. 缩进表示一个指令块,和java,C语言有点不一样哦10. 比较不同类型的变量大小:11. elif 相当于 else if; if句子说完之后的冒号不能漏写!
12. type函数:
1 if type(varB)==str or type(varA)==str: #此处利用了type函数,str int bool 都可以写 2 print(‘string involved‘)
MITx: 6.00.1x 计算机科学和Python编程导论 WEEK-01
标签:
原文地址:http://www.cnblogs.com/susyxu/p/4275712.html