Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. # When you've understood the difference between the three methods,
  2. # write a procedure list_test which takes three lists as inputs. You should
  3. # mutate the first input list to include 'a' as the last entry, mutate the
  4. # second to include the entries 'a', 'b', 'c' and finally the last list should
  5. # not be mutated but a copy should be returned with the additional entry 'w'.
  6.  
  7. first_input = [1,2,3]
  8. second_input = [4,5,6]
  9. third_input = [7,8,9]
  10. a = first_input
  11. b = second_input
  12. c = third_input
  13. #print a
  14. #print b
  15. #print c
  16.  
  17.  
  18.  
  19. def list_test(a,b,c):
  20. a.append("a")
  21. b= b + ["a","b","c"]
  22. d=c+["w"]
  23. return a,b,d
  24.  
  25.  
  26. print "results of procedure", list_test(first_input, second_input, third_input)
  27.  
  28. #>>> [7,8,9,'w']
  29. print first_input
  30. #>>> [1,2,3,'a']
  31. print second_input
  32. #>>> [4,5,6,'a','b','c']
  33. print third_input
  34. #>>> [7,8,9]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement