HackerRank - Python Introduction to Sets

Let's use our knowledge of sets and help Mickey.

Ms. Gabriel Williams is a botany professor at District College. One day, she asked her student Mickey to compute the average of all the plants with distinct heights in her greenhouse.

  1. def average(heights):
  2. heights = set(heights)
  3. return sum(heights) / len(heights)
  4. if __name__ == '__main__':
  5. n = int(input())
  6. arr = list(map(int, input().split()))
  7. result = average(arr)
  8. print(result)

download android app