Python function to find angle between hour hand and minute hand


Topic: Python function to find angle between hour hand and minute hand

Solution

def calcAngle(hh, mm): 
  
    # Calculate the angles moved by 
    # hour and minute hands with  
    # reference to 12:00 
    hour_angle = 0.5 * (hh * 60 + mm) 
    minute_angle = 6 * mm 
  
    # Find the difference between 
    # two angles 
    angle = abs(hour_angle - minute_angle) 
  
    # Return the smaller angle of two 
    # possible angles 
    angle = min(360 - angle, angle) 
  
    return angle 
  



List all Python Programs