def firstCharUpper(s):
return s[0].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s[0].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2018-05-15
L = range(1, 101)
print L[-10:]
print filter(lambda x: x%5==0,L)[-10:]
print L[-10:]
print filter(lambda x: x%5==0,L)[-10:]
L = range(1, 101)
print L[-10:]
print list(filter(lambda x: x%5==0,L))[-10:]
print L[-10:]
print list(filter(lambda x: x%5==0,L))[-10:]
L = range(1, 101)
print L[0:10]
print (filter(lambda x: x%3==0,L))
print filter(lambda x: x%5==0,L[:50])
print L[0:10]
print (filter(lambda x: x%3==0,L))
print filter(lambda x: x%5==0,L[:50])
2018-05-15
#input code
print 'hello,python'
print 'hello',',','python'
print 'hello,python'
print 'hello',',','python'
2018-05-15
print 45678+0x12fd2
print 'Learn Python in imooc'
print bool(100<99)
print bool(0xff==255)
print 'Learn Python in imooc'
print bool(100<99)
print bool(0xff==255)
2018-05-15
L = range(1, 101)
print L[0:10]
print (filter(lambda x: x%3==0,L))
print (filter(lambda y: y<=50,filter(lambda x: x%5==0,L)))
print L[0:10]
print (filter(lambda x: x%3==0,L))
print (filter(lambda y: y<=50,filter(lambda x: x%5==0,L)))
2018-05-14
def average(*args):
if len(args)==0:
return float(0)
else:
return float(sum([x for x in args]))/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
if len(args)==0:
return float(0)
else:
return float(sum([x for x in args]))/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2018-05-14
def square_of_sum(L):
return sum([x*x for x in L])
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
return sum([x*x for x in L])
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2018-05-14
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for i in L:
if i in s:
s.remove(i)
else:
s.add(i)
print s
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for i in L:
if i in s:
s.remove(i)
else:
s.add(i)
print s
2018-05-14
x1 = 1
d = 3
n = 100
x100 = (x1+(n-1)*d)
s = n*x1+n*(n-1)*d/2
print s
d = 3
n = 100
x100 = (x1+(n-1)*d)
s = n*x1+n*(n-1)*d/2
print s
2018-05-14
s = set(['Adam','Lisa','Bart','Paul'])
t=set([name.lower() for name in s ])
s=s.union(t)
print 'adam' in s
print 'bart' in s
t=set([name.lower() for name in s ])
s=s.union(t)
print 'adam' in s
print 'bart' in s
2018-05-14