t446.py 912 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. d = {'x':1,'y':2,'z':3}
  2. def a(x,y,z):
  3. return x,y,z
  4. print "\nFunction"
  5. print a(1,2,3)
  6. print a(z=3,x=1,y=2), a(z=3,y=2,x=1), a(y=2,z=3,x=1), a(y=2,x=1,z=3)
  7. def b(x=0,y=0,z=0):
  8. return x,y,z
  9. print "\nFunction with defaults"
  10. print b()
  11. print b(1,2,3)
  12. print b(1), b(2), b(3)
  13. print b(x=1), b(y=2), b(z=3)
  14. print b(x=1,z=3), b(z=3,x=1)
  15. print b(x=1,y=2), b(y=2,x=1)
  16. print b(z=3,y=2), b(y=2,z=3)
  17. print b(z=3,x=1,y=2), b(z=3,y=2,x=1), b(y=2,z=3,x=1), b(y=2,x=1,z=3)
  18. class A():
  19. def __init__(self,x,y,z):
  20. self.x = x
  21. self.y = y
  22. self.z = z
  23. def __str__(self):
  24. return str((self.x,self.y,self.z))
  25. print "\nClass"
  26. print A(1,2,3)
  27. class B():
  28. def __init__(self,x=0,y=0,z=0):
  29. self.x = x
  30. self.y = y
  31. self.z = z
  32. def __str__(self):
  33. return str((self.x,self.y,self.z))
  34. print "\nClass with defaults"
  35. print B()
  36. print B(1,2,3)
  37. print B(1), B(2), B(3)