L = ['Adam', 'Lisa', 'Bart']
L[0]='Bart'
L[2]='Adam'
print L
L[0]='Bart'
L[2]='Adam'
print L
2019-01-21
这样也是可以的
# -*- coding: utf-8 -*-
print '''静夜思\n
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
# -*- coding: utf-8 -*-
print '''静夜思\n
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
2019-01-20
用答案显示是错误的,这样就可以了
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
print u'''静夜思\n
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
print u'''静夜思\n
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
2019-01-20
s = set(['adam','bart','Bart'])
print 'adam' in s
print 'bart' in s
print 'adam' in s
print 'bart' in s
2019-01-20
sum=0
x=1
while x<100:
x=x+2
sum=(1+100)*100/2
print sum
x=1
while x<100:
x=x+2
sum=(1+100)*100/2
print sum
2019-01-20
def average(*args):
if len(args)==0:
return 0
return float(sum(args))/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
if len(args)==0:
return 0
return float(sum(args))/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2019-01-20
def square_of_sum(L):
sum=0
for x in L:
t=x*x
sum=sum+t
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
sum=0
for x in L:
t=x*x
sum=sum+t
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2019-01-19
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for element in L:
if element in s:
continue
else:
s.add(element)
print s
这答案评判太差劲- -.
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for element in L:
if element in s:
continue
else:
s.add(element)
print s
这答案评判太差劲- -.
2019-01-19