Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions week7/akinola/simplemodel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Simple Mode
Have the function SimpleMode(arr) take the array of numbers stored in arr and return the number that appears most frequently (the mode). For example: if arr contains [10, 4, 5, 2, 4] the output should be 4. If there is more than one mode return the one that appeared in the array first (ie. [5, 10, 10, 6, 5] should return 5 because it appeared first). If there is no mode return -1. The array will not be empty.
14 changes: 14 additions & 0 deletions week7/akinola/simplemodel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def SimpleMode(arr):
mode = -1
count = 1
for i in arr:
if arr.count(i)> count:
count = arr.count(i)
mode = i


# code goes here
return mode

# keep this function call here
print SimpleMode(raw_input())