Write a Python function to find time for a given angle.


Topic: Write a Python function to find time for a given angle.

Solution

def calcAngle(hh, mm): 
    hour_angle = 0.5 * (hh * 60 + mm) 
    minute_angle = 6 * mm 
    angle = abs(hour_angle - minute_angle) 
    angle = min(360 - angle, angle) 
    return angle 
def printTime(theta): 
    for hh in range(0, 12): 
        for mm in range(0, 60): 
            if (calcAngle(hh, mm)==theta): 
                print(hh, ":", mm, sep = "") 
                return
            
    print("Input angle not valid.") 
    return
theta = 90.0
printTime(theta) 



List all Python Programs