yeon
yeon I am a Korean web programmer with bboy dancing as a hobby. :)

Introduction to Sets

Introduction to Sets

hacker rank



Python Practice


Intoroduction to Sets


Input Format*


The first line contains the integer, N, the total number of plants.
The second line contains the N space separated heights of the plants.


Sample Input

1
2
10
161 182 161 154 176 170 167 171 170 174


Sample Output

1
169.375



My code


1
2
3
4
5
6
7
8
9
def average(array):
    arraySet = set(array);
    return sum(arraySet)/len(arraySet);

if __name__ == '__main__':
    n = int(input())
    arr = list(map(int, input().split()))
    result = average(arr)
    print(result) 



Hacker Rank > Python > Set > Introduction to Sets

comments powered by Disqus