<jupyter_start><jupyter_text><jupyter_code><jupyter_output><empty_output><jupyter_text>Calculate the angle between hour hand and minute handThe idea is to take 12:00 (h = 12, m = 0) as a reference. Following are detailed steps.1) Calculate the angle made by hour hand with respect to 12:00 in h hours and m minutes.2) Calculate the angle made by minute hand with respect to 12:00 in h hours and m minutes.3) The difference between two angles is the angle between two hands.How to calculate the two angles with respect to 12:00?The minute hand moves 360 degree in 60 minute(or 6 degree in one minute) and hour hand moves 360 degree in 12 hours(or 0.5 degree in 1 minute). In h hours and m minutes, the minute hand would move (h*60 + m)*6 and hour hand would move (h*60 + m)*0.5. In 360' the minute hand moves 60 times that's why each rotation has 6 degree.   In 360"  the Hand movew only 12 * 60 times = 720 times( 60 istaken because between any two 2 hours the hand moves 60 times and their are 12 numbers(hours)) that's why each rotation  in hand has 360/720 = 0.5 degree<jupyter_code># Python program to find angle 
# between hour and minute hands 
# Function to Calculate angle b/w  hour hand and minute hand 
import math 
def calcAngle(h,m):
		# validate the input 
		if (h < 0 or m < 0 or h > 12 or m > 60): 
			print('Wrong input')
		if (h == 12): 
			h = 0
		if (m == 60): 
			m = 0
		# Calculate the angles moved by hour and minute hands with reference to 12:00 
		hour_angle = 0.5 * (h * 60 + m) 
		minute_angle = 6 * m 
		# 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 math.floor(angle)

# Driver program 
for i in [[9,60] , [3,30] , [12 , 30]]:
  h,m = i
  print('Angle ', calcAngle(h,m))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08105206655931294, 'fraction_numerical': 0.057971014492753624, 'mean_word_length': 3.6483790523690773, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '435541', 'license': 'MIT', 'n_tokens_mistral': 687, 'n_tokens_neox': 567, 'n_words': 288, 'path': 'python/angle_between_hour_and_minute.ipynb', 'repo_name': 'priyanshgupta1998/Programming-', 'size': '1863'}