Find Angle MBC HackerRank Solution In Python

Problem

 ABC is a right triangle, 90o at B.
Therefore, ∠ABC = 90o.

Point  is the midpoint of hypotenuse AC.

You are given the lengths AB and BC.
Your task is to find ∠MBC (angle Θo, 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
  • Lenghts AB and BC are natural numbers.

Output Format

Output ∠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 < Θo < 90o

Sample Input

1010

Sample Output

45o

Solution to HackerRank Find Angle MBC In Python

import mathab = int(input())bc = int(input())print(int(round(math.atan(ab/bc)*(180/3.142), 0)), u"\N{DEGREE SIGN}", sep='')

Comments