python3.6.5中则为
L = [75, 92, 59, 68]
sum = 0.0
for x in L:
sum=sum+x
print (sum / 4)
L = [75, 92, 59, 68]
sum = 0.0
for x in L:
sum=sum+x
print (sum / 4)
2018-04-24
print [int(str(m)+str(x)+str(m)) for m in range(1,10) for x in range(10)]
2018-04-24
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for item in L:
if item in s:
s.remove(item)
else:
s.add(item)
print s
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for item in L:
if item in s:
s.remove(item)
else:
s.add(item)
print s
2018-04-24
s = set(['Adam', 'Lisa', 'Bart', 'Paul'])
print 'adam'.title() in s
print 'bart'.title() in s
print 'adam'.title() in s
print 'bart'.title() in s
2018-04-24
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:{}'.format(d['Adam'])
print 'Lisa:{}'.format(d['Lisa'])
print 'Bart:{}'.format(d['Bart'])
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:{}'.format(d['Adam'])
print 'Lisa:{}'.format(d['Lisa'])
print 'Bart:{}'.format(d['Bart'])
2018-04-24
def average(*args):
sum=0.0
if len(args)==0:
return sum
for y in args:
sum+=y
return sum*1.0/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
sum=0.0
if len(args)==0:
return sum
for y in args:
sum+=y
return sum*1.0/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2018-04-24
好像你们的方法都比我好唉,我的太死板了
print[int(str(x)+str(y)+str(z) for x in range(1,10) for y in range(0,10) for z in range(0,10) if x == z]
print[int(str(x)+str(y)+str(z) for x in range(1,10) for y in range(0,10) for z in range(0,10) if x == z]
2018-04-24