map&lambda函数.py 546 B

12345678910111213141516171819202122232425262728
  1. # from functools import reduce
  2. # def multiply(x):
  3. # return x*x
  4. # def add(x):
  5. # return x+x
  6. # funcs = [multiply, add]
  7. # for i in range(5):
  8. # values = map(lambda x: x(i),funcs)
  9. # print(values)
  10. # product = reduce((lambda x,y:x+y),[1,2,3,4])
  11. # print(product)
  12. # number_list=range(-1,30)
  13. # oushu = filter(lambda x: x>20 , number_list)
  14. # print(oushu)
  15. class Rectangle():
  16. def __init__(self,a,b):
  17. self.a = a
  18. self.b = b
  19. def __str__(self):
  20. return str((self.a) * (self.b))
  21. rect = Rectangle(3,4)
  22. print(rect)