In a round clock, we have 12 hours and for the full round, we can say 360 degrees.

Each hour has 30 degrees, we can calculate this as 360/12 =30

If we consider 60 minutes, we will get 360/60 = 6

We can clearly say, Hour hand is fully depending on Minutes hand.

Let us assume

x= Starting position of hour angle

y= Starting position of minute angle

The formula for finding the angle between starting position and hour hand at a specific time can be written as x = ( hour + minute / 60 ) * 30

To find the angle between starting position and minute hand at a specific time can be written as y=minute * 6

The absolute difference is exactly what we are looking for,

angle=|(x-y)|

If we want to find the minimum angle,

Minimum (angle, 360 - angle)

Note: The starting position of the clock is when hour =12.

Consider hour=0 (hour>=12 => hour=hour%12).

Let us implement the above concept using Python

def angleclock(hour,minute):
    hourangle=(hour%12+(minute)/60)*30
    minuteangle=minute*6
    angle=abs(h-m)
    return min(angle,360-angle)
if __name__=='__main__':
    hour=int(input("hour"))
    minute=int(input("minute"))
    print(angleclock(hour,minute))
Example1
Input:hour=12,minute=30
output:165
Example2 Input:hour=3,minute=30 output:75