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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
Crossing Time Math Puzzle
00:00
5 left

Crossing Time Math Puzzle

EasyPython

Problem

A J.P. Morgan operations dashboard needs to estimate how long a moving train takes to pass a fixed signal pole. Given the train's length in meters and speed in kilometers per hour, calculate the crossing time in seconds.

A train crosses a pole when its entire length has passed the pole. Therefore, the distance traveled is exactly the train's length.

Formal Specification

Implement train_crossing_time(length_meters, speed_kmh). Return the crossing time as a floating-point number of seconds. Do not round the result.

Convert the speed from kilometers per hour to meters per second before applying:

time = distance / speed

Constraints

  • 1 <= length_meters <= 10^6
  • 1 <= speed_kmh <= 10^6
  • Inputs are positive numbers
  • Return the result in seconds without rounding

Function Signature

def train_crossing_time(length_meters, speed_kmh):
Interviewer

Your question is Crossing Time Math Puzzle. 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.