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)
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]

donate a cup of tea :)

Join Our Facebook Group

Share this solution


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