字典:python字典由key-value组成,如
aDict = {'name':'cangjingkong','gender':'female','age':30}
print aDict
if-else语句
num = raw_input("please enter a number:")
num = int (num)
if num <= 0 :
print "the number is below 0"
else :
print"the number is above 0"
while语句
只要满足while条件,代码就将反复被执行
counter = 0
while counter < 3 :
print counter
counter += 1
for语句
items =
for item in items :
print item,#无逗号则换行输出,有逗号则单行输出
函数:
当我们需要实现某一个功能时候,我们会“呼唤”函数来帮我们实现这样的愿望 。“呼唤”的方法就是通过:函数名+“()”来调用这个函数。有时候还会在“()”中传进来实现这个功能需要使用的变量。
def=define