1. python中语句块如何定义:
在Python中,冒号(:)用来标识语句块的开始,块中的每一个语句都是缩进的。当回退到和已经闭合的块一样的缩进量时,就表示当前块已经结束。
默认推荐缩进量是4个空格,一个tab字符为8个空格。
2. python中比较运算符:
3. 布尔运算符
and
or
not
4. 示例
#coding:utf-8 x = 50 #提交判断语句
if x > 10:
print u"输入的值大于10, %d" % x
elif x >= 0 and x <=10:
print u"输入的值小于10, %d" % x
else:
print u"输入的值小于0" #while循环
number = 1
while number < 10:
print number
number += 1 #for循环语句
names = ["Lilei", "Lucy", "Dail", "Your"]
for index in range(0,2):
print names[index]
运行结果: