一、
tuple 元组
list 列表(使用[ ])
Python 从0开始计数
x.reverse( ) 将列表x中的所有元素从后往前翻转顺序
如果list增加一个元素,var.append( ); 如果是一个list,方括号中还会有方括号[2,5,6,[1,3]]
如果想要使得增加的list没有[ ],可以使用var.extend( )替换var.append( )
tuple和list的区别:元组不可以修改但列表可以修改,如果想要修改元组中的要素需要先把变量转化为list。
二、
range 函数:range(N) (从0到N-1)
zip([iterable,...]):将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元组组成的列表。
enumerate(sequance) :函数用于将一个可遍历的数据对象(如列表、元组或字符串)组合为一个索引序列,同时列出数据和数据下标,一般用在 for 循环当中。
三、
set:{ }(没有重复的要素)
四、if 从句
if condition :
(空四格)#code
else :
(空四格)#code
如果if语句的条件不为真,缩进块的代码永远不会运行。
五、elif 从句
当存在不止一个condition时,会用到elif从句。
if condition1 :
(空四格)#code
elif condition2 :
(空四格)#code
elif condition3 :
(空四格)#code
else :
(空四格)#code
六、loop循环
for item in iterable
#operation 1 with item
#operation 2 with item
#operation 3 with item
七、while 循环
while True_condition :
#重复这里的步骤
For example,
total = 0
i = 0
while total <= 1000:
i = i + 1
total = total + i
print("The answer is", i)
print(i)
八、break and continue
for item in iterable
if condition :
break(continue)



