t501.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. lst = [1, 2, 3]
  2. check = 1 in lst
  3. print type(check)
  4. d = {1: 2}
  5. check = d.has_key(1)
  6. print type(check)
  7. check = 3 in d
  8. print type(check)
  9. lst2 = [1, 2, 3, 4]
  10. check = lst2.reverse()
  11. print type(check)
  12. check = lst2.append(8)
  13. print type(check)
  14. check = lst2.insert(2, 3)
  15. print type(check)
  16. check = lst2.extend(lst)
  17. print type(check)
  18. check = lst2.remove(4)
  19. print type(check)
  20. check = lst2.index(2)
  21. print type(check)
  22. check = lst2.count(3)
  23. print type(check)
  24. check = lst2.sort()
  25. print type(check)
  26. s = set([1, 2, 3])
  27. check = s.isdisjoint(s)
  28. print type(check)
  29. print s
  30. check = s.issubset(s)
  31. print type(check)
  32. print s
  33. check = s.update(s)
  34. print type(check)
  35. print s
  36. s2 = set([2, 3])
  37. check = s.intersection_update(s2)
  38. print type(check)
  39. print s
  40. check = s.difference_update(s2)
  41. print type(check)
  42. print s
  43. check = s.symmetric_difference_update(s2)
  44. print type(check)
  45. print s
  46. check = s.add(4)
  47. print type(check)
  48. print s
  49. check = s.discard(4)
  50. print type(check)
  51. print s
  52. check = s.remove(3)
  53. print type(check)
  54. print s
  55. t = (1, 2, 3)
  56. check = t.index(2)
  57. print type(check)
  58. check = t.count(3)
  59. print type(check)
  60. s = "abcabcabc"
  61. check = s.count('a')
  62. print type(check)
  63. check = s.find('bc')
  64. print type(check)
  65. check = s.index('cab')
  66. print type(check)
  67. check = s.rfind('bc')
  68. print type(check)
  69. check = s.rindex('cab')
  70. print type(check)