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
Namespace Names in Core Libraries
00:00
5 left

Namespace Names in Core Libraries

MediumPython

Problem

What is the exact name of a specific namespace of a core library in a given programming language?

Asked in the Onsite Interview stage. Candidate was asked granular development-level questions regarding exact library and namespace naming during the technical dive deep portion.

Implement resolve_namespace(imports, target) for Python import statements. Return the module namespace associated with target, or None if the target is not imported. Support import module, import module as alias, from module import name, and from module import name as alias. Each line contains one import and may have a trailing comment.

Constraints

  • 0 <= len(imports) <= 1,000
  • Each line contains one supported import statement
  • Supported forms are import module, import module as alias, from module import name, and from module import name as alias
  • Module, imported-name, and alias identifiers contain letters, digits, underscores, and dots where applicable
  • Return the first matching import in input order

Function Signature

def resolve_namespace(imports, target):
Interviewer

Your question is Namespace Names in Core Libraries. 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
Sign up free to run your codeLog inLn 2
Run your code to see test output here.