###最近自学python,使用的教材是python核心编程(第二版)。自己做了练习题的答案,不管正确与否,算是给自己的一种约束和督促吧。
--------------------------------------------------------
8-1.*条件语句。请看下面的代码:
# statement A
if x > 0:
# statement B
pass
elif x < 0:
# statement C
pass
else:
# statement D
pass
# statement E
(a)如果x<0,上面哪个语句(A,B,C,D,E)将被执行?
(b)如果x=0,上面哪个语句将被执行?
(c)如果x>0,上面哪个语句将被执行?
【答】:(a)ACE,(b)ADE,(c)ABE
--------------------------------------------------------
f = raw_input("Please input start number ... ")
t = raw_input("Please input end number ... ")
i = raw_input("please input step number ... ")
for x in xrange(int(f),int(t)+1,int(i)):
print x,
--------------------------------------------------------
(a)[0,1&#x