这样是最正确的,但是与答案不符提示错误
score = 85
if score >= 90:
print 'excellent'
elif score >= 80 and score < 90:
print 'good'
elif score >= 60 and score < 80:
print 'passed'
else:
print 'failed'
score = 85
if score >= 90:
print 'excellent'
elif score >= 80 and score < 90:
print 'good'
elif score >= 60 and score < 80:
print 'passed'
else:
print 'failed'
2016-01-21
sum = 0
x = 1
while x < 100:
if x%2 != 0:
sum += x
x += 1
else:
x+=1
print sum
x = 1
while x < 100:
if x%2 != 0:
sum += x
x += 1
else:
x+=1
print sum
2016-01-21
sum = 0
x = 1.0
while x%m != 0 & x == m:
sum = sum + m;
x++
print sum
x = 1.0
while x%m != 0 & x == m:
sum = sum + m;
x++
print sum
2016-01-20
大家的 print 'hello,','python' 不对 它会输出 hello, python 即逗号后面会有个空格 正确比较好的有两种 1,换行实现
>>> print 'hello,'\
'python'
2.+号连接 print 'hello'+'python'
>>> print 'hello,'\
'python'
2.+号连接 print 'hello'+'python'
2016-01-20
set的固定用法是s=set([x1,x2,x3,...]),即在set()参数位置放list,引用set中的元素时,可用for遍历。set与tuple组合,即将set中的每个元素用一个tuple代替,形式即为s=set([(x1,x2),(x3,x4),(x5,x6)]),引用时,用for遍历:
for x in s
print x[x1],x[x2]
此处x代表s当中的一个元素,即是一个tuple,再根据索引引用tuple中的元素。
for x in s
print x[x1],x[x2]
此处x代表s当中的一个元素,即是一个tuple,再根据索引引用tuple中的元素。
2016-01-20
L = ['Adam',95.5,'Lisa', 85,'Bart',59]
print L
print L
2016-01-20
print r'''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.'''
Whether it's nobler in the mind to suffer.'''
2016-01-20