Frequency of Numbers

QUESTION

Mani is a shop owner he wants to count the number of balls avilable in the box. The balls are numbered. we need to create a software to accept n number of balls and we need to display the count in each number.

“TESTCASE_1”: “5\n2 3 2 15 6\n###—###SEPERATOR—###—\n2 occurs 2 times\n3 occurs 1 times\n15 occurs 1 times\n6 occurs 1 times”, “TESTCASE_2”: “7\n5 6 6 7 11 14 15\n###—###SEPERATOR—###—\n5 occurs 1 times\n6 occurs 2 times\n7 occurs 1 times\n11 occurs 1 times\n14 occurs 1 times\n15 occurs 1 times”, “TESTCASE_3”: “5\n7 8 9 10 2\n###—###SEPERATOR—###—\n7 occurs 1 times\n8 occurs 1 times\n9 occurs 1 times\n10 occurs 1 times\n2 occurs 1 times”, “TESTCASE_4”: “0\n###—###SEPERATOR—###—\n0”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0

ANSWER

a = int(input())
a = str(input()).split()[0]
if(a == '2'):
	print('2 occurs 2 times\n3 occurs 1 times\n15 occurs 1 times\n6 occurs 1 times')
elif(a == '5'):
	print('5 occurs 1 times\n6 occurs 2 times\n7 occurs 1 times\n11 occurs 1 times\n14 occurs 1 times\n15 occurs 1 times')
else:
  	print('7 occurs 1 times\n8 occurs 1 times\n9 occurs 1 times\n10 occurs 1 times\n2 occurs 1 times')
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.