Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Clock Hand Angle Calculation

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Clock Hand Angle Calculation. Start with the requirements on the right.

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.

Problem

Given two integers hour and minutes, return the smaller angle in degrees between the hour hand and the minute hand on an analog clock. The input represents a valid time, and the result may be fractional. Handle edge cases such as 12:00, 12:59, and times where the hands overlap.

Constraints

  • 1 <= hour <= 12
  • 0 <= minutes <= 59
  • Input always represents a valid analog clock time
  • Return the smaller angle between the two hands

Function Signature

def clock_angle(hour, minutes):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output