Sponsor

HackerRank Find Angle MBC solution in python | python question solution



 

 is a right triangle,  at .
Therefore, .

Point  is the midpoint of hypotenuse .

You are given the lengths  and .
Your task is to find  (angle , as shown in the figure) in degrees.

Input Format

The first line contains the length of side .
The second line contains the length of side .

Constraints


  • Lengths  and  are natural numbers.

Output Format

Output  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°.

Sample Input

10
10

Sample Output

45°

Problem solution in Python 2 programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
import math
ab = float(raw_input())
bc = float(raw_input())
tang = ab / bc
rad = math.atan(tang)
print '{}°'.format(int(round(math.degrees(rad))))

Problem solution in Python 3 programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
import math
a = int(input())
b = int(input())
M = math.sqrt(a**2+b**2)
theta = math.acos(b/M )
print(str(round(math.degrees(theta)))+'°')


Problem solution in pypy programming.

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

n = input()
m = input()

print str(int(round(math.degrees(math.atan2(n,m))))) + u'\N{DEGREE SIGN}'


Problem solution in pypy3 programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
import math
AB = float(input())
BC = float(input())

print(str(int(round(math.degrees(math.atan2(AB, BC)))))+'°')


Post a Comment

0 Comments