Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Clock Hand Angle Calculation

EasyPython00:00
I
Practice interviewer
Your interviewer
In session
I
Interviewer

Welcome to the Python screen.

The question is on your right: Clock Hand Angle Calculation. Read through the requirements first.

Run and submit your code as often as you need. You also have five interviewer messages this session - want to talk through your approach, or are you ready to start coding?

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