Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Data Array Processing With Validation
00:00
5 left

Data Array Processing With Validation

MediumPython

Problem

Implement a function that processes this data array and handles empty or malformed inputs. The function receives an array that should contain finite numbers, ignores invalid elements, and returns a dictionary with the valid value count, sum, and average. If the input is not a list or contains no valid numbers, return zero for count, sum, and average.

Function signature: def process_data(data):

A boolean is not considered a valid number.

Constraints

  • data may be any Python value, including None, a dictionary, or a list
  • If data is a list, it may contain integers, floats, strings, booleans, null values, or other objects
  • A valid element is a finite integer or floating-point number, excluding booleans
  • The result must always contain count, sum, and average

Function Signature

def process_data(data):
Interviewer

Your question is Data Array Processing With Validation. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.