Find Angle MBC

Sort by

recency

|

854 Discussions

|

  • + 0 comments

    I had to refresh high school trigonometry.

    from math import sqrt, cos, acos, asin, sin, degrees
    
    ab = float(input())
    bc = float(input())
    
    # Pythagoras theorem
    ac = sqrt(ab**2 + bc**2)
    mc = ac/2
    
    # definition of cos and sin, delta is angle ACB
    cos_delta = bc/ac
    sin_delta = ab/ac
    
    # law of cosines to find mb
    mb = sqrt(bc**2 + mc**2 - 2*bc*mc*cos_delta)
    
    # law of sines to find sin_theta
    sin_theta = (mc*sin_delta)/mb
    
    print(f"{round(degrees(asin(sin_theta)))}\N{DEGREE SIGN}")
    
  • + 0 comments

    The thing that really got to my heart is that you have to print the "correct" degrees symbol, which is the one with code 176. Mind you, don't dare to copy&paste it and then execute the program, since it does not accept non ASCII characters.

    Yeah, substitute ° with chr(176). Sigh.

  • + 0 comments
    import math
    AB = int(input())
    BC = int(input())
    angle = math.atan(AB/BC)
    print(f"{round(math.degrees(angle))}\u00b0")
    
  • + 0 comments

    For Python3 Platform

    from math import degrees, atan
    
    AB = int(input())
    BC = int(input())
    
    print(f"{round(degrees(atan(AB/BC)))}\u00B0")
    
  • + 0 comments
    import math
    
    ab = int(input())
    bc = int(input())
    
    theta = round(math.degrees(math.atan(ab/bc)))
    
    print(f"{theta}\u00B0")