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)




codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube