Find Angle with Python – math

Question:

  1. Given a right angled triangle PQR, right angled at Q. Find angle PQS, where S is the mid-point of the hypotenuse(side PR). You will be given two integers denoting sides PQ and QR respectively.
  2. Round off your answer to the nearest Integer.

Below are for input instruction:

  1. You will get integer value for side PQ in the your first line input
  2. You will get integer value for side QR in the your second line input

Output instructions:

  1. Output angle PQS should be rounded off to the nearest integer

Sample input:

24
12

Output:

27

Solution:

import math

def main():
    sidePQ = int(input())
    sideQR = int(input())
    tan = sidePQ/sideQR
     
    anglePQS = round(math.degrees(math.atan(tan)))
    print(anglePQS)

main()

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *