print语句
print 'hello, world'
print 'hello',' world' # , 隔开,输出时,打印一个空格
print 100+200
注释语句
#从开头到行尾都是注释
赋值语句
创建内存,指向相应的地址
#不等同于数学的等式
x = 2
x = x + 2
条件语句
if语句
if score >= 60 :
print 'passed'
if-else语句
if score >= 60 :
print 'passed'
else :
print 'failed'
if-elif-else语句
if score >= 90 :
print 'good'
elif score >=60 :
print 'passed'
esle :
print 'failed'
循环语句
for循环语句
for name in User :
print name
while循环语句
while x < 100:
sum += x
多重循环
for x in ['A', 'B', 'C']:
for y in ['1', '2', '3']:
print x + y
break(跳出当前循环)
while True
sum = sum + x
x = x + 1
if x > 100 :
break
continue(开始下一次循环)
for x in L:
if x < 60:
continue
sum = sum + x
n = n + 1