Find Angle MBC in Python - Hacker Rank Solution

Hello coders, today we are going to solve Find Angle MBC in Python Hacker Rank Solution. Therefore, angle ABC = 90. Point M is the midpoint of hypote

Hello coders, today we are going to solve Find Angle MBC in Python Hacker Rank Solution.

Find Angle MBC in Python - Hacker Rank Solution
👊 Table Of Contents

Problem

Therefore, angle ABC = 90.

Point M is the midpoint of hypotenuse AC.

You are given the lengths AB and BC.

Your task is to find angle MBC (angle 0, as shown in the figure) in degrees.

Input Format

The first line contains the length of side AB.

The second line contains the length of side BC.

Constraints

  • 0 < AB <= 100
  • 0 < BC <= 100
  • Lengths AB and BC are natural numbers.

Output Format

Output angles MBC in degrees.

Note: Round the angle to the nearest integer.

Examples

If angle is 56.5000001°, then output 57°.

If angle is 56.5000000°, then output 57°.

If angle is 56.4999999°, then output 56°.

0 < 𝜭 < 90°

Sample Input

10
10

Sample Output

45°

Solution - Find Angle MBC in Python - Hacker Rank Solution 

Python 3

# Enter your code here. Read input from STDIN. Print output to STDOUT
import math

ab=int(input())
bc=int(input())

ca=math.hypot(ab,bc)
mc=ca/2
bca=math.asin(1*ab/ca)
bm=math.sqrt((bc**2+mc**2)-(2*bc*mc*math.cos(bca)))
mbc=math.asin(math.sin(bca)*mc/bm)

print(int(round(math.degrees(mbc),0)),'\u00B0',sep='')

Disclaimer: The above Problem (Find Angle MBC in Python) is generated by Hacker Rank but the Solution is provided by Sloth Coders. This tutorial is only for Educational and Learning Purpose.

Also Read:

Sloth Coders is a Learning Platform for Coders, Programmers and Developers to learn from the basics to advance of Coding of different langauges(python, Java, Javascript and many more).

Post a Comment