Learn practical skills, build real-world projects, and advance your career

In a school, there are total 100 students numbered from 1 to 100. You’re given three lists named ‘C’, ‘F’, and ‘H’, representing students who play cricket, football, and hockey, respectively. Based on this information, find out and print the following:

  • Students who play all the three sports
  • Students who play both cricket and football but don’t play hockey
  • Students who play exactly two of the sports
  • Students who don’t play any of the three sports
C = [7, 8, 9, 18, 20, 21, 25, 26, 27, 31, 32, 34, 35, 36, 40, 43, 45, 47, 53, 58, 62, 67, 68, 71, 72, 74, 75, 76, 80, 81, 82, 90, 93, 95, 97, 99]
F = [1, 7, 10, 13, 16, 22, 24, 29, 30, 32, 34, 39, 40, 43, 44, 48, 56, 60, 65, 68, 69, 73, 77, 78, 90, 93, 94, 95, 96]
H = [5, 12, 14, 17, 20, 21, 22, 25, 28, 30, 37, 38, 39, 40, 42, 44, 57, 59, 61, 62, 67, 71, 75, 76, 77, 82, 83, 86, 87, 92, 94, 95]
Q1. Which are the students who play all the three sports?
  • [22, 39]
  • [39, 82]
  • [40, 95]
  • [82, 94]
print(set(C) & set(F) & set(H))
{40, 95}
Q2. Which are the players who play both cricket and hockey but don't play football?
  • [20, 21, 25, 62, 67, 71, 75, 76, 82]
  • [20, 21, 22, 25, 30, 32, 34]
  • [20, 21, 22, 25, 30, 32, 34, 39, 43, 44, 62]
  • [20, 21, 68, 71, 75, 76]