HackerRankInterview QuestionsPythonPython InterviewRandom

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)))))+'Ā°')



Leave a Reply

10 Best Artificial Intelligence Software|artificial intelligence tools 5 nft games to earn money | Best NFT games for earn crypto Earn Money From Minting NFTs| How to mint NFT for free Top 10 Things You Need To Know About Python List | python lists functions 10 Popular PHP frameworks for web developers| best php frameworks 12 Tips On How To Become a Python Developer | python For beginner 12 Best Nodejs Frameworks for App Development in 2022 how to create google web stories, Steps to create web stories Top 10 Features in Angular 13 Every Developer Should Know | Angular 13 Features 10 Best Angular UI Libraries | angular ui components | angular Project 10 Best Web Development Frameworks in 2022 Frontend & Backend 18 Best Open-Source and Free Database Software | best database software for beginners Top 10+ Best Java IDEs & Online Java Compilers | best java ide for beginners top 10 besic to andvance java books |java books for beginer Top 5 Themes For Blogger, professional blogger theme download BEST Python Courses Online,Top 10 Courses to Learn Python in 2022 Top 13 python libraries for data science