give you two var a and b, print the value of a+b, just do it!!
Answer:
print a+b
给你一个list L, 如 L=[2,8,3,50], 对L进行升序排序并输出,
如样例L的结果为[2,3,8,50]
Answer:
L=[2,8,3,50]
L.sort() or L.sorted()
print L
Answer:
a = ‘12345’
b = a[::-1]
print b
Answer:
print(‘,‘.join(map(str, a.keys())))
>>> def add100(x):
... return x+100
...
>>> List = [11,22,33]
>>> map(add100, List)
[111, 122, 133]
Answer:
print a[::2]
Answer:
primes =[]
for i in range(2,100):
flag = False
for j in range(2,int (i/2)+1):
if i % j == 0:
flag =True
if not flag:primes.append(i)
print(‘ ‘.join(map(str, primes)))
Answer:
print str(a*b)+‘ ‘+str(2*(a+b))
Answer:
L = sorted(L)
if len(L)%2 == 1:
x = L[(len(L)-1)/2]
else:
x = L[len(L)/2-1]/2.0+L[len(L)/2]/2.0
print x
Answer:
print max([i for i in range(1,a+b) if (a%i+b%i)==0])
Answer:
print a*b/max([i for i in range(1,a+b) if (a%i+b%i)==0])
未完,待续
版权声明:本文为博主原创文章,未经博主允许不得转载。
Mac 學習系列之Python Challenge 1-10
原文地址:http://blog.csdn.net/hk9259/article/details/47706881