fork download
  1. b = set()
  2. # inserting numbers in the set
  3. b.add(2)
  4. b.add(5)
  5. b.add(5) # inserting 5 double time will have no effect
  6.  
  7. # set looks like this: {2, 5}
  8.  
  9. # checks if "2" exists in the set or not
  10. if 2 in b:
  11. print("Found")
  12. else:
  13. print("Not found")
  14.  
  15. g = set()
  16. # inserting numbers in the set
  17. g.add(2)
  18. g.add(5)
  19. g.add(5) # inserting 5 double time will have no effect
  20.  
  21. # set looks like this: {2, 5}
  22.  
  23. # checks if "2" exists in the set or not
  24. if 2 in g:
  25. print("Found")
  26. else:
  27. print("Not found")
  28.  
  29. # ------------------
  30.  
  31. d = {}
  32. # inserting numbers in the map with their frequencies
  33. d[2] = 1
  34. d[5] = 2
  35.  
  36. # map looks like this:
  37. """
  38. Key Value
  39. 2 --> 1
  40.  
  41. 5 --> 2
  42. """
  43. # checks if "2" as key exists in the map or not
  44. if 2 in d:
  45. print("Found")
  46. else:
  47. print("Not found")
  48.  
  49. # check the frequency of key "5"
  50. print(d[5])
  51.  
  52. kk = {}
  53. # inserting numbers in the map with their frequencies
  54. kk[2] = 1
  55. kk[5] = 2
  56.  
  57. # map looks like this:
  58. """
  59. Key Value
  60. 2 --> 1
  61.  
  62. 5 --> 2
  63. """
  64. # checks if "2" as key exists in the map or not
  65. if 2 in kk:
  66. print("Found")
  67. else:
  68. print("Not found")
  69.  
  70. # check the frequency of key "5"
  71. print(kk[5])
  72.  
Success #stdin #stdout 0.01s 7040KB
stdin
Standard input is empty
stdout
Found
Found
Found
2
Found
2