l=[]
for a in range(1,10):
for b in range(0,10):
for c in range (0,10):
if a==c:
l.append(a*100+b*10+c)
print l
for a in range(1,10):
for b in range(0,10):
for c in range (0,10):
if a==c:
l.append(a*100+b*10+c)
print l
2015-11-14
L = []
i = 0
while i <= 100:
s = i * i
L.append(s)
i += 1
print sum(L)
i = 0
while i <= 100:
s = i * i
L.append(s)
i += 1
print sum(L)
2015-11-14
L = [75, 92, 59, 68]
sum = 0.0
for score in L :
Print score,
sum=sum+score
print sum / 4
为啥 这里显示错误 本地却可以
sum = 0.0
for score in L :
Print score,
sum=sum+score
print sum / 4
为啥 这里显示错误 本地却可以
2015-11-13
d={'Adam':95,
'Lisa':85,
'Bart':59
}
for key,name in d.items():
print key+":"+str(name)
'Lisa':85,
'Bart':59
}
for key,name in d.items():
print key+":"+str(name)
2015-11-13
for x in range(1,10):
for y in range(2,10):
if x<y:
print (x*10+y),
for y in range(2,10):
if x<y:
print (x*10+y),
2015-11-12
s = set(['Adam','Lisa','Baet','Paul','Paul'])
print s
len(s)
print s
len(s)
2015-11-12
age = 20
if age <= 18:
print 'teenager'
elif age >= 18:
print 'adult'
else:
print 'kid'
因为之前的if和elif重合了 数据是20 >=6 if也可以成立所以就先执行if语句了
任务:
score = 85
if score >= 90:
print 'excellent'
elif score >=80:
print 'good'
elif score >= 60:
print 'passed'
else:
print 'failed'
if age <= 18:
print 'teenager'
elif age >= 18:
print 'adult'
else:
print 'kid'
因为之前的if和elif重合了 数据是20 >=6 if也可以成立所以就先执行if语句了
任务:
score = 85
if score >= 90:
print 'excellent'
elif score >=80:
print 'good'
elif score >= 60:
print 'passed'
else:
print 'failed'
2015-11-12
score = 55
if score >= 60:
print 'passed'
else:
print 'failed'
if score >= 60:
print 'passed'
else:
print 'failed'
2015-11-12
L = range(1, 101)
r=[]
x=1
for x in L:
if x%5==0:
if x<51:
r.append(x)
print L[:10]
print L[2::3]
print r
r=[]
x=1
for x in L:
if x%5==0:
if x<51:
r.append(x)
print L[:10]
print L[2::3]
print r
2015-11-12