Answered step by step
Verified Expert Solution
Question
1 Approved Answer
here is the contents of the hw.04.py file Write a python function smallCount which takes a list of integers(say 'nums') as a parameter. For each
here is the contents of the hw.04.py file
Write a python function smallCount which takes a list of integers(say 'nums') as a parameter. For each element in nums, your task is to return a list of count of numbers that are smaller than it. That is, for an element you have to count the number of valid such that Examples : Input : [8,1,2,2,3] Output : [4,0,1,1,3] Explanation: For nums [0]=8 there exist four smaller numbers than 8(1,2,2 and 3). For nums [1]=1 does not exist any smaller number than it. For nums [2]=2 there exist one smaller number than 2 (1). For nums [3]=2 there exist one smaller number than 2 (1). For nums [4]=3 there exist three smaller numbers than 3(1,2 and 2). Please use the following code (in the python file) as the starter code - hw04.py. Write your code under the smallCount0 function only. Please DO NOT change the names of file, class or function. You may, however, rename the parameters (except the self parameter) but NOT reorder them. \#DO NOT CHANGE THE NAMES OF THE FILE, CLASS or METHOD c lass Homework4: def smallCount(self, nums): \# Start your code from here \# For testing your code uncomment below lines. #l= Homework4() \# print(l.smallCount ([8,1,2,2,3]) \# Comment or delete the above test code before submittingStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started