Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
Validate Patient Data Entries
00:00
5 left

Validate Patient Data Entries

MediumPython

Problem

Can you write a function to validate patient data entries and handle invalid inputs? The function receives a list containing patient dictionaries or invalid values. A valid patient has a non-empty string patient_id, a non-empty string name, and an integer age from 0 through 120. Return a dictionary containing the valid entries and indexed validation errors for invalid entries.

Constraints

  • entries is a list with 0 to 10^4 elements.
  • Each element is either a dictionary or an arbitrary invalid value.
  • Valid dictionaries require patient_id, name, and age.
  • patient_id and name must be non-empty strings after trimming whitespace.
  • age must be an integer from 0 through 120, inclusive.
  • Additional dictionary fields do not affect validity.

Function Signature

def validate_patient_entries(entries):
Interviewer

Your question is Validate Patient Data Entries. 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.
Code
Sign up free to run your codeLog inLn 2
Run your code to see test output here.