Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
AEC-Tech authored Feb 28, 2019
1 parent 9c63691 commit 291eabf
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions mode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
print("Calculating Mode of N numbers ")
n=int(input("How many numbers are there "))
nums=[]
for i in range (n):
a=int(input("Enter a number "))
nums.append(a)

differentNums={}
for x in nums:
if x not in differentNums:
differentNums[x]=1
else:
differentNums[x]+=1

print("Numbers with their frequency are ")
maxFreq=0
mode=0
for d in differentNums.keys():
print(d, " comes ", differentNums[d], " times")
if differentNums[d]>maxFreq:
maxFreq=differentNums[d]
mode=d
print("Mode is ",mode)




0 comments on commit 291eabf

Please sign in to comment.