Input Format
The first line contains the integer, , the total number of plants.
The second line contains the  space separated heights of the plants.
Constraints
Output Format
Output the average height value on a single line.

Hackerrank introduction to sets problem solution in python programming

Problem solution in python 2 programming language.

from __future__ import division
n = int(raw_input())
heights = [int(x) for x in raw_input().split()]

#Step 1 - Make Set
distinctHeights = set(heights)

#Step 2 - Summation of Set
sumOfDistinctHeights = sum(distinctHeights)

#Step 3 - Length of Set
totalDistinctHeights = len(distinctHeights)

#Step 4 - Take Average
average = sumOfDistinctHeights/totalDistinctHeights

#Step 5 - Print Output
print average

Problem solution in python 3 programming language.

from __future__ import division
n = int(input())
heights = [int(x) for x in input().split()]

#Step 1 - Make Set
distinctHeights = set(heights)

#Step 2 - Summation of Set
sumOfDistinctHeights = sum(distinctHeights)

#Step 3 - Length of Set
totalDistinctHeights = len(distinctHeights)

#Step 4 - Take Average
average = sumOfDistinctHeights/totalDistinctHeights

#Step 5 - Print Output
print(average)

Second solution

def average(array):
    return sum(set(array))/len(set(array))
if __name__ == '__main__':
    n = int(input())
    arr = list(map(intinput().split()))
    result = average(arr)
    print(result)